diff --git a/src/hooks/usePantry.ts b/src/hooks/usePantry.ts index 25a1dc7..55e860e 100644 --- a/src/hooks/usePantry.ts +++ b/src/hooks/usePantry.ts @@ -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 { diff --git a/src/hooks/useSync.ts b/src/hooks/useSync.ts index b1e4087..2663570 100644 --- a/src/hooks/useSync.ts +++ b/src/hooks/useSync.ts @@ -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