fix: snapshot notion wal files

This commit is contained in:
Vincent Koc 2026-04-22 15:59:43 -07:00
parent 63f6f8e6d2
commit 263e6357b8
No known key found for this signature in database

View File

@ -101,9 +101,34 @@ func snapshotDB(path, cacheDir string) (string, error) {
if _, err := io.Copy(out, in); err != nil {
return "", err
}
for _, suffix := range []string{"-wal", "-shm"} {
src := path + suffix
if _, err := os.Stat(src); err == nil {
if err := copyFile(src, outPath+suffix, 0o600); err != nil {
return "", err
}
} else if !os.IsNotExist(err) {
return "", err
}
}
return outPath, nil
}
func copyFile(src, dst string, perm os.FileMode) error {
in, err := os.Open(src)
if err != nil {
return err
}
defer in.Close()
out, err := os.OpenFile(dst, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, perm)
if err != nil {
return err
}
defer out.Close()
_, err = io.Copy(out, in)
return err
}
func ingestSpaces(ctx context.Context, st *store.Store, db *sql.DB) (int, error) {
rows, err := db.QueryContext(ctx, `select id, coalesce(name, ''), coalesce(json_object(
'id', id, 'name', name, 'pages', pages, 'settings', settings, 'created_time', created_time, 'last_edited_time', last_edited_time