瀏覽代碼

Gracefully handle deletion of files in app cache

Neeraj Gupta 3 年之前
父節點
當前提交
6e1f5558af
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      lib/utils/delete_file_util.dart

+ 4 - 1
lib/utils/delete_file_util.dart

@@ -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);