summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDees Troy <dees_troy@teamw.in>2013-03-18 15:57:29 +0100
committerGerrit Code Review <gerrit@5.9.244.119>2013-03-18 15:57:29 +0100
commit7289a181d86563670b899ebb36d65f81be57bc93 (patch)
treeba44f18a8dc71b4efc0a22ea3c14a03e3ba80cfa
parentFix backup of initial directory with split archives (diff)
parenttrying to fix md5 (diff)
downloadandroid_bootable_recovery-7289a181d86563670b899ebb36d65f81be57bc93.tar
android_bootable_recovery-7289a181d86563670b899ebb36d65f81be57bc93.tar.gz
android_bootable_recovery-7289a181d86563670b899ebb36d65f81be57bc93.tar.bz2
android_bootable_recovery-7289a181d86563670b899ebb36d65f81be57bc93.tar.lz
android_bootable_recovery-7289a181d86563670b899ebb36d65f81be57bc93.tar.xz
android_bootable_recovery-7289a181d86563670b899ebb36d65f81be57bc93.tar.zst
android_bootable_recovery-7289a181d86563670b899ebb36d65f81be57bc93.zip
Diffstat (limited to '')
-rw-r--r--partition.cpp22
-rw-r--r--partitionmanager.cpp6
-rw-r--r--twrpDigest.cpp5
-rw-r--r--twrpDigest.hpp2
4 files changed, 23 insertions, 12 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;
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 9beb2575f..4364a2252 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -501,12 +501,8 @@ bool TWPartitionManager::Make_MD5(bool generate_md5, string Backup_Folder, strin
string strfn;
sprintf(filename, "%s%03i", Full_File.c_str(), index);
strfn = filename;
- ostringstream intToStr;
- ostringstream fn;
while (TWFunc::Path_Exists(filename) == true) {
- intToStr << index;
- fn << setw(3) << setfill('0') << intToStr.str();
- md5sum.setfn(strfn);
+ md5sum.setfn(filename);
if (md5sum.computeMD5() == 0) {
if (md5sum.write_md5digest() != 0)
{
diff --git a/twrpDigest.cpp b/twrpDigest.cpp
index 16cda3d68..add498c6c 100644
--- a/twrpDigest.cpp
+++ b/twrpDigest.cpp
@@ -84,7 +84,7 @@ int twrpDigest::write_md5digest(void) {
int twrpDigest::read_md5digest(void) {
string md5file = md5fn + ".md5";
- if (TWFunc::read_file(md5file, lines) != 0)
+ if (TWFunc::read_file(md5file, line) != 0)
return -1;
return 0;
}
@@ -94,10 +94,9 @@ int twrpDigest::verify_md5digest(void) {
char hex[3];
int i;
string md5string;
-
if (read_md5digest() != 0)
return -1;
- stringstream ss(lines.at(0));
+ stringstream ss(line);
vector<string> tokens;
while (ss >> buf)
tokens.push_back(buf);
diff --git a/twrpDigest.hpp b/twrpDigest.hpp
index 80828fca5..395c0aea1 100644
--- a/twrpDigest.hpp
+++ b/twrpDigest.hpp
@@ -30,6 +30,6 @@ class twrpDigest {
private:
int read_md5digest(void);
string md5fn;
- vector<string> lines;
+ string line;
unsigned char md5sum[MD5LENGTH];
};