Merge pull request #309 from ente-io/fix-uncaught-unlink-error
Ignore file missing error on unlink
This commit is contained in:
commit
3b058e4451
1 changed files with 13 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue