瀏覽代碼

Discard backup file if it fails to be created properly (e.g. fails validation)

arkon 3 年之前
父節點
當前提交
76d2c676fd
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      app/src/main/java/eu/kanade/tachiyomi/data/backup/full/FullBackupManager.kt

+ 3 - 1
app/src/main/java/eu/kanade/tachiyomi/data/backup/full/FullBackupManager.kt

@@ -59,8 +59,9 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
             )
         }
 
+        var file: UniFile? = null
         try {
-            val file: UniFile = (
+            file = (
                 if (isJob) {
                     // Get dir of file and create
                     var dir = UniFile.fromUri(context, uri)
@@ -93,6 +94,7 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
             return fileUri.toString()
         } catch (e: Exception) {
             logcat(LogPriority.ERROR, e)
+            file?.delete()
             throw e
         }
     }