fix(platform): normalize native paths for storage and backup validation

This commit is contained in:
eezd committed 2026-10-27 15:03:57 +08:00
1 parent bea53ce3c8
commit 1a8f70ca13
9 files changed
+120 -8

No files matched your search

+10 -1
View File
@@ -5,6 +5,7 @@ import (
"database/sql"
"encoding/json"
"net/url"
"path/filepath"
"rawmark/internal/i18n"
"strings"
)
@@ -83,7 +84,15 @@ func (s *Store) CheckBackup() error {
// OpenExisting opens only existing databases; import validation must not create tables or change journal modes.
func OpenExisting(path string) (*Store, error) {
db, err := sql.Open("sqlite", (&url.URL{Scheme: "file", Path: path, RawQuery: "mode=rw&_pragma=busy_timeout(5000)"}).String())
absolute, err := filepath.Abs(path)
if err != nil {
return nil, err
}
uriPath := filepath.ToSlash(absolute)
if filepath.VolumeName(absolute) != "" && !strings.HasPrefix(uriPath, "/") {
uriPath = "/" + uriPath
}
db, err := sql.Open("sqlite", (&url.URL{Scheme: "file", Path: uriPath, RawQuery: "mode=rw&_pragma=busy_timeout(5000)"}).String())
if err != nil {
return nil, err
}