mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 16:18:55 +01:00 
			
		
		
		
	Always attempt automatic backup creation
- Defaults to every 12 hours - Minimum number of backups is now 2, just to offer some level of redundancy in case something happens - If it's missing storage permissions, it'll fail but that's the user's loss if they somehow haven't granted that permission yet
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
package eu.kanade.tachiyomi.data.backup
 | 
			
		||||
 | 
			
		||||
import android.Manifest
 | 
			
		||||
import android.content.Context
 | 
			
		||||
import android.net.Uri
 | 
			
		||||
import com.hippo.unifile.UniFile
 | 
			
		||||
@@ -34,6 +35,7 @@ import eu.kanade.tachiyomi.data.database.models.Track
 | 
			
		||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
 | 
			
		||||
import eu.kanade.tachiyomi.source.SourceManager
 | 
			
		||||
import eu.kanade.tachiyomi.source.model.copyFrom
 | 
			
		||||
import eu.kanade.tachiyomi.util.system.hasPermission
 | 
			
		||||
import eu.kanade.tachiyomi.util.system.logcat
 | 
			
		||||
import eu.kanade.tachiyomi.util.system.toLong
 | 
			
		||||
import kotlinx.serialization.protobuf.ProtoBuf
 | 
			
		||||
@@ -68,6 +70,10 @@ class BackupManager(
 | 
			
		||||
     */
 | 
			
		||||
    @Suppress("BlockingMethodInNonBlockingContext")
 | 
			
		||||
    suspend fun createBackup(uri: Uri, flags: Int, isAutoBackup: Boolean): String {
 | 
			
		||||
        if (!context.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
 | 
			
		||||
            throw IllegalStateException(context.getString(R.string.missing_storage_permission))
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        val databaseManga = getFavorites.await()
 | 
			
		||||
        val backup = Backup(
 | 
			
		||||
            backupMangas(databaseManga, flags),
 | 
			
		||||
 
 | 
			
		||||
@@ -214,7 +214,7 @@ class PreferencesHelper(val context: Context) {
 | 
			
		||||
 | 
			
		||||
    fun numberOfBackups() = flowPrefs.getInt("backup_slots", 2)
 | 
			
		||||
 | 
			
		||||
    fun backupInterval() = flowPrefs.getInt("backup_interval", 0)
 | 
			
		||||
    fun backupInterval() = flowPrefs.getInt("backup_interval", 12)
 | 
			
		||||
 | 
			
		||||
    fun removeAfterReadSlots() = prefs.getInt(Keys.removeAfterReadSlots, -1)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user