Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mtime-ms #87

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading