diff --git a/api.go b/api.go index 5c065b1..160c532 100644 --- a/api.go +++ b/api.go @@ -171,7 +171,7 @@ func apiNote(dir string, w http.ResponseWriter, r *http.Request, readOnly bool) return } - if !info.ModTime().UTC().Equal(notePatch.LastMtime.UTC()) { + if !info.ModTime().Truncate(time.Second).UTC().Equal(notePatch.LastMtime.Truncate(time.Second).UTC()) { respondWithError(w, "Refusing to overwrite. File changed on disk.", http.StatusConflict) return } @@ -230,7 +230,7 @@ func apiNote(dir string, w http.ResponseWriter, r *http.Request, readOnly bool) return } - if !info.ModTime().UTC().Equal(noteDelete.LastMtime.UTC()) { + if !info.ModTime().Truncate(time.Second).UTC().Equal(noteDelete.LastMtime.Truncate(time.Second).UTC()) { respondWithError(w, "Refusing to delete. File changed on disk.", http.StatusConflict) return } diff --git a/cache.go b/cache.go index 059f7ea..a2b471e 100644 --- a/cache.go +++ b/cache.go @@ -85,7 +85,7 @@ func readNote(dir string, filename string) (*Note, error) { if err != nil { return nil, fmt.Errorf("could not get file info: %s", err) } - mtime := info.ModTime() + mtime := info.ModTime().Truncate(time.Second) hexTime := strings.TrimSuffix(filename, ".md") unixTime, err := strconv.ParseInt(hexTime, 16, 64)