소스 검색

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