summaryrefslogtreecommitdiffstats
path: root/partitionmanager.cpp
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2016-09-19 20:50:25 +0200
committerJames Christopher Adduono <jc@adduono.com>2016-10-24 13:17:32 +0200
commitfa4ff144374474c541351d153549ad11d4396614 (patch)
tree86dd5f6d955ced589d375f914d5d73f452aeafb2 /partitionmanager.cpp
parentFix libcrypto dependency in 6.0 trees (diff)
downloadandroid_bootable_recovery-fa4ff144374474c541351d153549ad11d4396614.tar
android_bootable_recovery-fa4ff144374474c541351d153549ad11d4396614.tar.gz
android_bootable_recovery-fa4ff144374474c541351d153549ad11d4396614.tar.bz2
android_bootable_recovery-fa4ff144374474c541351d153549ad11d4396614.tar.lz
android_bootable_recovery-fa4ff144374474c541351d153549ad11d4396614.tar.xz
android_bootable_recovery-fa4ff144374474c541351d153549ad11d4396614.tar.zst
android_bootable_recovery-fa4ff144374474c541351d153549ad11d4396614.zip
Diffstat (limited to 'partitionmanager.cpp')
-rw-r--r--partitionmanager.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 738f6ce3c..b04cc9ab8 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -486,7 +486,7 @@ bool TWPartitionManager::Make_MD5(PartitionSettings *part_settings)
if (part_settings->Part == NULL)
return false;
- string Full_File = part_settings->Backup_Folder + part_settings->Part->Backup_FileName;
+ string Full_File = part_settings->Backup_Folder + "/" + part_settings->Part->Backup_FileName;
twrpDigest md5sum;
if (!part_settings->generate_md5)
@@ -622,7 +622,7 @@ void TWPartitionManager::Clean_Backup_Folder(string Backup_Folder) {
if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, ".."))
continue;
- string path = Backup_Folder + p->d_name;
+ string path = Backup_Folder + "/" + p->d_name;
size_t dot = path.find_last_of(".") + 1;
if (path.substr(dot) == "win" || path.substr(dot) == "md5" || path.substr(dot) == "info") {
@@ -647,7 +647,7 @@ int TWPartitionManager::Cancel_Backup() {
if (tar_fork_pid != 0) {
DataManager::GetValue(TW_BACKUP_NAME, Backup_Name);
DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, Backup_Folder);
- Full_Backup_Path = Backup_Folder + "/" + Backup_Name + "/";
+ Full_Backup_Path = Backup_Folder + "/" + Backup_Name;
LOGINFO("Killing pid: %d\n", tar_fork_pid);
kill(tar_fork_pid, SIGUSR2);
while (kill(tar_fork_pid, 0) == 0) {
@@ -714,9 +714,9 @@ int TWPartitionManager::Run_Backup(bool adbbackup) {
}
LOGINFO("Backup Name is: '%s'\n", Backup_Name.c_str());
- part_settings.Backup_Folder = part_settings.Backup_Folder + "/" + Backup_Name + "/";
+ part_settings.Backup_Folder = part_settings.Backup_Folder + "/" + Backup_Name;
- LOGINFO("Full_Backup_Path is: '%s'\n", part_settings.Backup_Folder.c_str());
+ LOGINFO("Backup_Folder is: '%s'\n", part_settings.Backup_Folder.c_str());
LOGINFO("Calculating backup details...\n");
DataManager::GetValue("tw_backup_list", Backup_List);
@@ -864,7 +864,7 @@ int TWPartitionManager::Run_Backup(bool adbbackup) {
Update_System_Details();
UnMount_Main_Partitions();
gui_msg(Msg(msg::kHighlight, "backup_completed=[BACKUP COMPLETED IN {1} SECONDS]")(total_time)); // the end
- string backup_log = part_settings.Backup_Folder + "recovery.log";
+ string backup_log = part_settings.Backup_Folder + "/recovery.log";
TWFunc::copy_file("/tmp/recovery.log", backup_log, 0644);
tw_set_default_metadata(backup_log.c_str());
@@ -2248,13 +2248,13 @@ bool TWPartitionManager::Remove_MTP_Storage(unsigned int Storage_ID) {
return false;
}
-bool TWPartitionManager::Flash_Image(PartitionSettings *part_settings) {
+bool TWPartitionManager::Flash_Image(string& path, string& filename) {
int check, partition_count = 0;
TWPartition* flash_part = NULL;
string Flash_List, flash_path, full_filename;
size_t start_pos = 0, end_pos = 0;
- full_filename = part_settings->Backup_Folder;
+ full_filename = path + "/" + filename;
gui_msg("image_flash_start=[IMAGE FLASH STARTED]");
gui_msg(Msg("img_to_flash=Image to flash: '{1}'")(full_filename));
@@ -2269,6 +2269,14 @@ bool TWPartitionManager::Flash_Image(PartitionSettings *part_settings) {
}
}
+ PartitionSettings part_settings;
+ part_settings.Backup_Folder = path;
+ unsigned long long total_bytes = TWFunc::Get_File_Size(full_filename);
+ ProgressTracking progress(total_bytes);
+ part_settings.progress = &progress;
+ part_settings.adbbackup = false;
+ part_settings.PM_Method = PM_RESTORE;
+
gui_msg("calc_restore=Calculating restore details...");
DataManager::GetValue("tw_flash_partition", Flash_List);
if (!Flash_List.empty()) {
@@ -2298,7 +2306,8 @@ bool TWPartitionManager::Flash_Image(PartitionSettings *part_settings) {
DataManager::SetProgress(0.0);
if (flash_part) {
- if (!flash_part->Flash_Image(part_settings))
+ flash_part->Backup_FileName = filename;
+ if (!flash_part->Flash_Image(&part_settings))
return false;
} else {
gui_err("invalid_flash=Invalid flash partition specified.");