fix: snapshot notion wal files
This commit is contained in:
parent
63f6f8e6d2
commit
263e6357b8
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user