mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 19:27:25 +01:00
Return success/failure result for backup job
This commit is contained in:
parent
81b2dfd9d0
commit
19507d1837
@ -20,8 +20,11 @@ class BackupCreatorJob(private val context: Context, workerParams: WorkerParamet
|
|||||||
val backupManager = BackupManager(context)
|
val backupManager = BackupManager(context)
|
||||||
val uri = Uri.parse(preferences.backupsDirectory().get())
|
val uri = Uri.parse(preferences.backupsDirectory().get())
|
||||||
val flags = BackupCreateService.BACKUP_ALL
|
val flags = BackupCreateService.BACKUP_ALL
|
||||||
backupManager.createBackup(uri, flags, true)
|
return if (backupManager.createBackup(uri, flags, true)) {
|
||||||
return Result.success()
|
Result.success()
|
||||||
|
} else {
|
||||||
|
Result.failure()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -102,7 +102,7 @@ class BackupManager(val context: Context, version: Int = CURRENT_VERSION) {
|
|||||||
* @param uri path of Uri
|
* @param uri path of Uri
|
||||||
* @param isJob backup called from job
|
* @param isJob backup called from job
|
||||||
*/
|
*/
|
||||||
fun createBackup(uri: Uri, flags: Int, isJob: Boolean) {
|
fun createBackup(uri: Uri, flags: Int, isJob: Boolean): Boolean {
|
||||||
// Create root object
|
// Create root object
|
||||||
val root = JsonObject()
|
val root = JsonObject()
|
||||||
|
|
||||||
@ -169,6 +169,7 @@ class BackupManager(val context: Context, version: Int = CURRENT_VERSION) {
|
|||||||
}
|
}
|
||||||
context.sendLocalBroadcast(intent)
|
context.sendLocalBroadcast(intent)
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e)
|
Timber.e(e)
|
||||||
if (!isJob) {
|
if (!isJob) {
|
||||||
@ -179,6 +180,7 @@ class BackupManager(val context: Context, version: Int = CURRENT_VERSION) {
|
|||||||
}
|
}
|
||||||
context.sendLocalBroadcast(intent)
|
context.sendLocalBroadcast(intent)
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user