backup: fix return handling when no digest is being created
If the user selects to skip digest creation, Backup_Partition always returned
false. This patch fixes this problem and somewhat cleans up the error
handling.
Change-Id: I1db0e285cd5ed2bd93756cd27c6f56b8415ffa86
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 0b00eb0..f70159c 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -529,14 +529,12 @@
time(&start);
if (part_settings->Part->Backup(part_settings, &tar_fork_pid)) {
- bool digestSuccess = false;
+ sync();
+ sync();
string Full_Filename = part_settings->Backup_Folder + "/" + part_settings->Part->Backup_FileName;
- if (part_settings->generate_digest) {
-
- if (part_settings->adbbackup)
- digestSuccess = true;
- else
- digestSuccess = twrpDigestDriver::Make_Digest(Full_Filename);
+ if (!part_settings->adbbackup && part_settings->generate_digest) {
+ if (!twrpDigestDriver::Make_Digest(Full_Filename))
+ goto backup_error;
}
if (part_settings->Part->Has_SubPartition) {
@@ -547,18 +545,13 @@
if ((*subpart)->Can_Be_Backed_Up && (*subpart)->Is_SubPartition && (*subpart)->SubPartition_Of == parentPart->Mount_Point) {
part_settings->Part = *subpart;
if (!(*subpart)->Backup(part_settings, &tar_fork_pid)) {
- Clean_Backup_Folder(part_settings->Backup_Folder);
- TWFunc::copy_file("/tmp/recovery.log", backup_log, 0644);
- tw_set_default_metadata(backup_log.c_str());
- TWFunc::SetPerformanceMode(false);
- return false;
+ goto backup_error;
}
sync();
sync();
if (!part_settings->adbbackup && part_settings->generate_digest) {
if (!twrpDigestDriver::Make_Digest(Full_Filename)) {
- TWFunc::SetPerformanceMode(false);
- return false;
+ goto backup_error;
}
}
}
@@ -577,15 +570,14 @@
}
TWFunc::SetPerformanceMode(false);
- return digestSuccess;
- } else {
- Clean_Backup_Folder(part_settings->Backup_Folder);
- TWFunc::copy_file("/tmp/recovery.log", backup_log, 0644);
- tw_set_default_metadata(backup_log.c_str());
- TWFunc::SetPerformanceMode(false);
- return false;
+ return true;
}
- return 0;
+backup_error:
+ Clean_Backup_Folder(part_settings->Backup_Folder);
+ TWFunc::copy_file("/tmp/recovery.log", backup_log, 0644);
+ tw_set_default_metadata(backup_log.c_str());
+ TWFunc::SetPerformanceMode(false);
+ return false;
}
void TWPartitionManager::Clean_Backup_Folder(string Backup_Folder) {