Skip to content
Closed
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
9 changes: 5 additions & 4 deletions src/hooks/usePantry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,11 @@ export default function usePantry() {
}

const neglected = () => {
if (!prefix.exists()) return true
const stat = Deno.statSync(prefix.string)
if (!stat.mtime) return true
return (Date.now() - stat.mtime.getTime()) > 24 * 60 * 60 * 1000
const last_sync_file = prefix.join(".last_sync")
if (!last_sync_file.exists()) return true
const last_sync_date = new Date(Deno.readTextFileSync(last_sync_file.string).trim());
if (!last_sync_date) return true
return (Date.now() - last_sync_date.getTime()) > 24 * 60 * 60 * 1000
}

return {
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/useSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ async function sync(pantry_dir: Path) {
proc.close()

}
// Write a file indicating last sync time
const now = new Date().toISOString()
const last_sync_file = pantry_dir.join("projects").join(".last_sync")
await Deno.writeTextFile(last_sync_file.string, now)
}

//////////////////////// utils
Expand Down