mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Use unified storage location for automatic backups
This commit is contained in:
		| @@ -21,6 +21,7 @@ import eu.kanade.tachiyomi.util.system.workManager | ||||
| import logcat.LogPriority | ||||
| import tachiyomi.core.util.system.logcat | ||||
| import tachiyomi.domain.backup.service.BackupPreferences | ||||
| import tachiyomi.domain.storage.service.StoragePreferences | ||||
| import uy.kohesive.injekt.Injekt | ||||
| import uy.kohesive.injekt.api.get | ||||
| import java.util.Date | ||||
| @@ -39,8 +40,9 @@ class BackupCreateJob(private val context: Context, workerParams: WorkerParamete | ||||
|         if (isAutoBackup && BackupRestoreJob.isRunning(context)) return Result.retry() | ||||
|  | ||||
|         val backupPreferences = Injekt.get<BackupPreferences>() | ||||
|  | ||||
|         val uri = inputData.getString(LOCATION_URI_KEY)?.toUri() | ||||
|             ?: backupPreferences.backupsDirectory().get().toUri() | ||||
|             ?: getAutomaticBackupLocation() | ||||
|         val flags = inputData.getInt(BACKUP_FLAGS_KEY, BackupCreateFlags.AutomaticDefaults) | ||||
|  | ||||
|         try { | ||||
| @@ -73,6 +75,15 @@ class BackupCreateJob(private val context: Context, workerParams: WorkerParamete | ||||
|         ) | ||||
|     } | ||||
|  | ||||
|     private fun getAutomaticBackupLocation(): Uri { | ||||
|         val storagePreferences = Injekt.get<StoragePreferences>() | ||||
|         return storagePreferences.baseStorageDirectory().get().let { | ||||
|             val dir = UniFile.fromUri(context, it.toUri()) | ||||
|                 .createDirectory(StoragePreferences.BACKUP_DIR) | ||||
|             dir.uri | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     companion object { | ||||
|         fun isManualJobRunning(context: Context): Boolean { | ||||
|             return context.workManager.isRunning(TAG_MANUAL) | ||||
|   | ||||
| @@ -47,7 +47,6 @@ class DownloadProvider( | ||||
|             val dir = UniFile.fromUri(context, it.toUri()) | ||||
|                 .createDirectory(StoragePreferences.DOWNLOADS_DIR) | ||||
|             DiskUtil.createNoMediaFile(dir, context) | ||||
|             logcat { "downloadsDir: ${dir.filePath}" } | ||||
|             dir | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -11,7 +11,6 @@ import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences | ||||
| import eu.kanade.tachiyomi.util.system.isDevFlavor | ||||
| import tachiyomi.core.preference.AndroidPreferenceStore | ||||
| import tachiyomi.core.preference.PreferenceStore | ||||
| import tachiyomi.core.provider.AndroidBackupFolderProvider | ||||
| import tachiyomi.core.provider.AndroidStorageFolderProvider | ||||
| import tachiyomi.domain.backup.service.BackupPreferences | ||||
| import tachiyomi.domain.download.service.DownloadPreferences | ||||
| @@ -53,13 +52,7 @@ class PreferenceModule(val app: Application) : InjektModule { | ||||
|             DownloadPreferences(get()) | ||||
|         } | ||||
|         addSingletonFactory { | ||||
|             AndroidBackupFolderProvider(app) | ||||
|         } | ||||
|         addSingletonFactory { | ||||
|             BackupPreferences( | ||||
|                 folderProvider = get<AndroidBackupFolderProvider>(), | ||||
|                 preferenceStore = get(), | ||||
|             ) | ||||
|             BackupPreferences(get()) | ||||
|         } | ||||
|         addSingletonFactory { | ||||
|             AndroidStorageFolderProvider(app) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user