fix(watch): capture Windows file identity before external moves

This commit is contained in:
eezd committed 2026-10-27 15:03:57 +08:00
1 parent 1a8f70ca13
commit 18bbb60a3b
4 files changed
+41 -4

No files matched your search

+12 -1
View File
@@ -10,6 +10,7 @@ import (
"os"
"path/filepath"
"rawmark/internal/i18n"
"runtime"
"sort"
"strings"
"time"
@@ -135,8 +136,18 @@ func (w *Watcher) scan() (map[string]fileState, error) {
next := make(map[string]fileState, len(entries))
dirs := map[string]bool{w.v.Root(): true}
for _, e := range entries {
st := fileState{dir: e.Dir, size: e.Size, mtime: e.Info.ModTime().UnixNano(), info: e.Info}
abs := filepath.Join(w.v.Root(), filepath.FromSlash(e.Path))
info := e.Info
if runtime.GOOS == "windows" {
info, err = snapshotInfo(abs)
if errors.Is(err, fs.ErrNotExist) {
continue
}
if err != nil {
return nil, err
}
}
st := fileState{dir: e.Dir, size: info.Size(), mtime: info.ModTime().UnixNano(), info: info}
if e.Dir {
dirs[abs] = true
} else if vault.IsNote(e.Path) {