Gracefully handle deletion of files in app cache

This commit is contained in:
Neeraj Gupta 2021-09-09 11:20:55 +05:30
parent 49a42cf2ac
commit 6e1f5558af

View file

@ -274,7 +274,10 @@ Future<List<String>> _tryDeleteSharedMediaFiles(List<String> localIDs) {
"/" +
id.replaceAll(kSharedMediaIdentifier, '');
try {
await io.File(localPath).delete();
// verify the file exists as the OS may have already deleted it from cache
if (io.File(localPath).existsSync()) {
await io.File(localPath).delete();
}
actuallyDeletedIDs.add(id);
} catch (e, s) {
_logger.warning("Could not delete file " + id, e, s);