Albirew/tachiyomi
Archivé
1
0
Bifurcation 0

Fix backup issue. Closes #806

Cette révision appartient à :
inorichi 2017-05-24 11:15:40 +02:00
Parent 211f7b591b
révision 73d1a1a05e
3 fichiers modifiés avec 12 ajouts et 10 suppressions

Voir le fichier

@ -50,9 +50,9 @@ class BackupCreateService : IntentService(NAME) {
* @param flags determines what to backup
* @param isJob backup called from job
*/
fun makeBackup(context: Context, path: String, flags: Int, isJob: Boolean = false) {
fun makeBackup(context: Context, uri: Uri, flags: Int, isJob: Boolean = false) {
val intent = Intent(context, BackupCreateService::class.java).apply {
putExtra(BackupConst.EXTRA_URI, path)
putExtra(BackupConst.EXTRA_URI, uri)
putExtra(EXTRA_IS_JOB, isJob)
putExtra(EXTRA_FLAGS, flags)
}
@ -67,11 +67,11 @@ class BackupCreateService : IntentService(NAME) {
if (intent == null) return
// Get values
val uri = intent.getStringExtra(BackupConst.EXTRA_URI)
val uri = intent.getParcelableExtra<Uri>(BackupConst.EXTRA_URI)
val isJob = intent.getBooleanExtra(EXTRA_IS_JOB, false)
val flags = intent.getIntExtra(EXTRA_FLAGS, 0)
// Create backup
createBackupFromApp(Uri.parse(uri), flags, isJob)
createBackupFromApp(uri, flags, isJob)
}
/**

Voir le fichier

@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.data.backup
import android.net.Uri
import com.evernote.android.job.Job
import com.evernote.android.job.JobManager
import com.evernote.android.job.JobRequest
@ -7,14 +8,15 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.io.File
class BackupCreatorJob : Job() {
override fun onRunJob(params: Params): Result {
val preferences = Injekt.get<PreferencesHelper>()
val path = preferences.backupsDirectory().getOrDefault()
val uri = Uri.fromFile(File(preferences.backupsDirectory().getOrDefault()))
val flags = BackupCreateService.BACKUP_ALL
BackupCreateService.makeBackup(context, path, flags, true)
BackupCreateService.makeBackup(context, uri, flags, true)
return Result.SUCCESS
}

Voir le fichier

@ -177,11 +177,11 @@ class SettingsBackupController : SettingsController() {
}
CODE_BACKUP_CREATE -> if (data != null && resultCode == Activity.RESULT_OK) {
val activity = activity ?: return
val path = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
val uri = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
val dir = data.data.path
val file = File(dir, Backup.getDefaultFilename())
file.absolutePath
Uri.fromFile(file)
} else {
val uri = data.data
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
@ -190,11 +190,11 @@ class SettingsBackupController : SettingsController() {
activity.contentResolver.takePersistableUriPermission(uri, flags)
val file = UniFile.fromUri(activity, uri)
file.uri.toString()
file.uri
}
CreatingBackupDialog().showDialog(router, TAG_CREATING_BACKUP_DIALOG)
BackupCreateService.makeBackup(activity, path, backupFlags)
BackupCreateService.makeBackup(activity, uri, backupFlags)
}
CODE_BACKUP_RESTORE -> if (data != null && resultCode == Activity.RESULT_OK) {
val uri = data.data