summaryrefslogtreecommitdiffstats
path: root/partition.cpp
diff options
context:
space:
mode:
authorbigbiff bigbiff <bigbiff@teamw.in>2013-03-15 20:17:50 +0100
committerbigbiff bigbiff <bigbiff@teamw.in>2013-03-17 19:40:20 +0100
commit65a4c73b1eea5f29f517d8357248c537dc6752ec (patch)
tree0aaa3c47052201c939de8886442b9fcf59d0b394 /partition.cpp
parent2.4.4.0 (diff)
downloadandroid_bootable_recovery-65a4c73b1eea5f29f517d8357248c537dc6752ec.tar
android_bootable_recovery-65a4c73b1eea5f29f517d8357248c537dc6752ec.tar.gz
android_bootable_recovery-65a4c73b1eea5f29f517d8357248c537dc6752ec.tar.bz2
android_bootable_recovery-65a4c73b1eea5f29f517d8357248c537dc6752ec.tar.lz
android_bootable_recovery-65a4c73b1eea5f29f517d8357248c537dc6752ec.tar.xz
android_bootable_recovery-65a4c73b1eea5f29f517d8357248c537dc6752ec.tar.zst
android_bootable_recovery-65a4c73b1eea5f29f517d8357248c537dc6752ec.zip
Diffstat (limited to 'partition.cpp')
-rw-r--r--partition.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/partition.cpp b/partition.cpp
index 346c298b2..681604f21 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -941,30 +941,46 @@ bool TWPartition::Backup(string backup_folder) {
}
bool TWPartition::Check_MD5(string restore_folder) {
- string Full_Filename;
+ string Full_Filename, md5file;
char split_filename[512];
int index = 0;
twrpDigest md5sum;
+ memset(split_filename, 0, sizeof(split_filename));
Full_Filename = restore_folder + "/" + Backup_FileName;
if (!TWFunc::Path_Exists(Full_Filename)) {
// This is a split archive, we presume
sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index);
+ LOGI("split_filename: %s\n", split_filename);
+ md5file = split_filename;
+ md5file += ".md5";
+ if (!TWFunc::Path_Exists(md5file)) {
+ LOGE("No md5 file found for '%s'.\n", split_filename);
+ LOGE("Please unselect Enable MD5 verification to restore.\n");
+ return false;
+ }
+ md5sum.setfn(split_filename);
while (index < 1000 && TWFunc::Path_Exists(split_filename)) {
- md5sum.setfn(split_filename);
if (md5sum.verify_md5digest() != 0) {
LOGE("MD5 failed to match on '%s'.\n", split_filename);
return false;
}
index++;
sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index);
+ md5sum.setfn(split_filename);
}
return true;
} else {
// Single file archive
+ md5file = Full_Filename + ".md5";
+ if (!TWFunc::Path_Exists(md5file)) {
+ LOGE("No md5 file found for '%s'.\n", Full_Filename.c_str());
+ LOGE("Please unselect Enable MD5 verification to restore.\n");
+ return false;
+ }
md5sum.setfn(Full_Filename);
if (md5sum.verify_md5digest() != 0) {
- LOGE("MD5 failed to match on '%s'.\n", split_filename);
+ LOGE("MD5 failed to match on '%s'.\n", Full_Filename.c_str());
return false;
} else
return true;