Merge pull request #309 from ente-io/fix-uncaught-unlink-error

Ignore file missing error on unlink
This commit is contained in:
Vishnu Mohandas 2024-01-11 11:42:14 +05:30 committed by GitHub
commit 3b058e4451
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -53,8 +53,19 @@ class DiskLRUService {
if (size >= maxSize) {
const leastRecentlyUsed =
await this.findLeastRecentlyUsed(cacheDir);
await unlink(leastRecentlyUsed.path);
try {
await unlink(leastRecentlyUsed.path);
} catch (e) {
// ENOENT: File not found
// which can be ignored as we are trying to delete the file anyway
if (e.code !== 'ENOENT') {
logError(
e,
'Failed to evict least recently used'
);
}
// ignoring the error, as it would get retried on the next run
}
this.evictLeastRecentlyUsed(cacheDir, maxSize);
}
resolve(null);