فهرست منبع

Avoid potentially deleting the entire backups folder

arkon 3 سال پیش
والد
کامیت
45da036789
1فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 5 1
      app/src/main/java/eu/kanade/tachiyomi/data/backup/full/FullBackupManager.kt

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

@@ -85,9 +85,13 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
                 )
                 ?: throw Exception("Couldn't create backup file")
 
+            if (!file.isFile) {
+                throw IllegalStateException("Failed to get handle on file")
+            }
+
             val byteArray = parser.encodeToByteArray(BackupSerializer, backup!!)
             file.openOutputStream().also {
-                // Force overwrite old file size,
+                // Force overwrite old file
                 (it as? FileOutputStream)?.channel?.truncate(0)
             }.sink().gzip().buffer().use { it.write(byteArray) }
             val fileUri = file.uri