Keep another process's downloads when opening a library (closes #105)
check / check (push) Successful in 1m18s
check / check (push) Successful in 1m18s
The download writer's temp files are now named .quak-<pid>-<random>.tmp. removeLeftoverTempFiles moves from the backup into the download module and deletes a .quak-*.tmp file only when the process ID in its name is no longer running; the content cache calls it at open() instead of deleting every temp file, so a download in progress in another process sharing the cache survives. The README backup layout and TODO.md are updated. Model: opus-5-5
This commit was merged in pull request #120.
This commit is contained in:
@@ -39,6 +39,7 @@ import {
|
||||
downloadFile,
|
||||
downloadThumbnail,
|
||||
type ProgressCallback,
|
||||
removeLeftoverTempFiles,
|
||||
} from "../download/index.js";
|
||||
import { safeExtension } from "../filename.js";
|
||||
import type { EnteFile } from "../model/types.js";
|
||||
@@ -46,8 +47,6 @@ import type { Priority, RequestPools } from "./pools.js";
|
||||
|
||||
const DIR_MODE = 0o700;
|
||||
const FILE_MODE = 0o600;
|
||||
const TEMP_PREFIX = ".quak-";
|
||||
const TEMP_SUFFIX = ".tmp";
|
||||
const GIB = 1024 * 1024 * 1024;
|
||||
// Owner ruling (#36): bound the originals cache at 100 GiB, but back off when
|
||||
// the volume has under 50 GiB free so the cache never crowds the disk.
|
||||
@@ -654,6 +653,9 @@ export class ContentCache implements PhotoContent, ThumbnailsAPI {
|
||||
}
|
||||
|
||||
private async scan(dir: string, into: Map<number, string>): Promise<void> {
|
||||
// Another process sharing this cache may still be writing its temp
|
||||
// files, so only those whose process has exited are removed.
|
||||
removeLeftoverTempFiles(dir);
|
||||
let entries: string[];
|
||||
try {
|
||||
entries = await readdir(dir);
|
||||
@@ -661,12 +663,6 @@ export class ContentCache implements PhotoContent, ThumbnailsAPI {
|
||||
return;
|
||||
}
|
||||
for (const name of entries) {
|
||||
if (name.startsWith(TEMP_PREFIX) && name.endsWith(TEMP_SUFFIX)) {
|
||||
await rm(join(dir, name), { force: true }).catch(
|
||||
() => undefined,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const id = fileIDFromName(name);
|
||||
const path = join(dir, name);
|
||||
if (id !== undefined && existsSync(path)) into.set(id, path);
|
||||
|
||||
Reference in New Issue
Block a user