mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 16:56:22 +02:00
feat: add seedFolderMtimes API for seeding file modification times during folder synchronization
This commit is contained in:
parent
e8c2377824
commit
d009d06432
6 changed files with 48 additions and 0 deletions
|
|
@ -449,14 +449,30 @@ export async function acknowledgeFileEvents(eventIds: string[]): Promise<{ ackno
|
|||
|
||||
const ackSet = new Set(eventIds);
|
||||
let acknowledged = 0;
|
||||
const foldersToUpdate = new Set<string>();
|
||||
|
||||
for (const [key, event] of outboxEvents.entries()) {
|
||||
if (ackSet.has(event.id)) {
|
||||
if (event.action !== 'unlink') {
|
||||
const map = mtimeMaps.get(event.folderPath);
|
||||
if (map) {
|
||||
try {
|
||||
map[event.relativePath] = fs.statSync(event.fullPath).mtimeMs;
|
||||
foldersToUpdate.add(event.folderPath);
|
||||
} catch {
|
||||
// File may have been removed
|
||||
}
|
||||
}
|
||||
}
|
||||
outboxEvents.delete(key);
|
||||
acknowledged += 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (const fp of foldersToUpdate) {
|
||||
persistMtimeMap(fp);
|
||||
}
|
||||
|
||||
if (acknowledged > 0) {
|
||||
persistOutbox();
|
||||
}
|
||||
|
|
@ -464,6 +480,17 @@ export async function acknowledgeFileEvents(eventIds: string[]): Promise<{ ackno
|
|||
return { acknowledged };
|
||||
}
|
||||
|
||||
export async function seedFolderMtimes(
|
||||
folderPath: string,
|
||||
mtimes: Record<string, number>,
|
||||
): Promise<void> {
|
||||
const ms = await getMtimeStore();
|
||||
const existing: MtimeMap = ms.get(folderPath) ?? {};
|
||||
const merged = { ...existing, ...mtimes };
|
||||
mtimeMaps.set(folderPath, merged);
|
||||
ms.set(folderPath, merged);
|
||||
}
|
||||
|
||||
export async function pauseWatcher(): Promise<void> {
|
||||
for (const [, entry] of watchers) {
|
||||
if (entry.watcher) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue