Skip to content

Commit

Permalink
feat: Do not reset list if operation failed
Browse files Browse the repository at this point in the history
Change-Id: I21fb87a344e7df245795e01b75328b533dd83ee3
  • Loading branch information
XayahSuSuSu committed Jan 9, 2025
1 parent c2d95e2 commit e259323
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ internal abstract class AbstractBackupService : AbstractMediumService() {
}
entity.update(progress = 0.5f)

if (mContext.readResetBackupList().first()) mMediaDao.clearActivated(OpType.BACKUP)
if (mContext.readResetBackupList().first() && mTaskEntity.failureCount == 0) {
mMediaDao.clearActivated(OpType.BACKUP)
}
if (runCatchingOnService { clear() }.not()) {
isSuccess = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ internal abstract class AbstractRestoreService : AbstractMediumService() {
mContext.getString(R.string.wait_for_remaining_data_processing)
)

if (mContext.readResetRestoreList().first()) mMediaDao.clearActivated(OpType.RESTORE)
if (mContext.readResetRestoreList().first() && mTaskEntity.failureCount == 0) {
mMediaDao.clearActivated(OpType.RESTORE)
}
val isSuccess = runCatchingOnService { clear() }
entity.update(progress = 1f, state = if (isSuccess) OperationState.DONE else OperationState.ERROR)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ internal abstract class AbstractBackupService : AbstractPackagesService() {
} else {
log { "AccessibilityServices is empty, skip restoring." }
}
if (mContext.readResetBackupList().first()) mPackageDao.clearActivated(OpType.BACKUP)
if (mContext.readResetBackupList().first() && mTaskEntity.failureCount == 0) {
mPackageDao.clearActivated(OpType.BACKUP)
}
if (runCatchingOnService { clear() }.not()) {
isSuccess = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ internal abstract class AbstractRestoreService : AbstractPackagesService() {
mContext.getString(R.string.wait_for_remaining_data_processing)
)

if (mContext.readResetRestoreList().first()) mPackageDao.clearActivated(OpType.RESTORE)
if (mContext.readResetRestoreList().first() && mTaskEntity.failureCount == 0) {
mPackageDao.clearActivated(OpType.RESTORE)
}
val isSuccess = runCatchingOnService { clear() }
entity.update(progress = 1f, state = if (isSuccess) OperationState.DONE else OperationState.ERROR)
}
Expand Down

0 comments on commit e259323

Please sign in to comment.