From 3fdcda46629e8e7fc19e89c51350b1e6f151e05e Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Wed, 30 Nov 2016 12:29:37 -0600 Subject: Improve backup & wipe exclusion handling Rename twrpDU.* to exclude.* Remove global variable for du and replace with partition specific variables. Use separate exclusion lists for backups and wiping. Clean up some includes Fix some parenthesis in twrp.cpp that I messed up. Note: twrpTarMain command line utility compiles but probably does not work correctly yet due to not properly setting part_settings Change-Id: Idec9c3e6a8782ba53f3420fa79ba33394f4f85fb --- twrpTar.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'twrpTar.cpp') diff --git a/twrpTar.cpp b/twrpTar.cpp index 06e3b629a..3c07a97d1 100644 --- a/twrpTar.cpp +++ b/twrpTar.cpp @@ -71,6 +71,7 @@ twrpTar::twrpTar(void) { tar_type.readfunc = read; input_fd = -1; output_fd = -1; + backup_exclusions = NULL; } twrpTar::~twrpTar(void) { @@ -108,12 +109,18 @@ int twrpTar::createTarFork(pid_t *tar_fork_pid) { char cmd[512]; file_count = 0; + if (backup_exclusions == NULL) { + LOGINFO("backup_exclusions is NULL\n"); + return -1; + } +#ifndef BUILD_TWRPTAR_MAIN if (part_settings->adbbackup) { std::string Backup_FileName(tarfn); if (!twadbbu::Write_TWFN(Backup_FileName, Total_Backup_Size, use_compression)) return -1; } +#endif if (pipe(progress_pipe) < 0) { LOGINFO("Error creating progress tracking pipe\n"); @@ -168,7 +175,7 @@ int twrpTar::createTarFork(pid_t *tar_fork_pid) { while ((de = readdir(d)) != NULL) { FileName = tardir + "/" + de->d_name; - if (de->d_type == DT_BLK || de->d_type == DT_CHR || du.check_skip_dirs(FileName)) + if (de->d_type == DT_BLK || de->d_type == DT_CHR || backup_exclusions->check_skip_dirs(FileName)) continue; if (de->d_type == DT_DIR) { item_len = strlen(de->d_name); @@ -183,9 +190,9 @@ int twrpTar::createTarFork(pid_t *tar_fork_pid) { _exit(-1); } file_count = (unsigned long long)(ret); - regular_size += du.Get_Folder_Size(FileName); + regular_size += backup_exclusions->Get_Folder_Size(FileName); } else { - encrypt_size += du.Get_Folder_Size(FileName); + encrypt_size += backup_exclusions->Get_Folder_Size(FileName); } } else if (de->d_type == DT_REG) { stat(FileName.c_str(), &st); @@ -216,7 +223,7 @@ int twrpTar::createTarFork(pid_t *tar_fork_pid) { while ((de = readdir(d)) != NULL) { FileName = tardir + "/" + de->d_name; - if (de->d_type == DT_BLK || de->d_type == DT_CHR || du.check_skip_dirs(FileName)) + if (de->d_type == DT_BLK || de->d_type == DT_CHR || backup_exclusions->check_skip_dirs(FileName)) continue; if (de->d_type == DT_DIR) { item_len = strlen(de->d_name); @@ -657,7 +664,7 @@ int twrpTar::Generate_TarList(string Path, std::vector *TarList, while ((de = readdir(d)) != NULL) { FileName = Path + "/" + de->d_name; - if (de->d_type == DT_BLK || de->d_type == DT_CHR || du.check_skip_dirs(FileName)) + if (de->d_type == DT_BLK || de->d_type == DT_CHR || backup_exclusions->check_skip_dirs(FileName)) continue; TarItem.fn = FileName; TarItem.thread_id = *thread_id; @@ -698,10 +705,12 @@ int twrpTar::extractTar() { gui_err("restore_error=Error during restore process."); return -1; } +#ifndef BUILD_TWRPTAR_MAIN if (part_settings->adbbackup) { if (!twadbbu::Write_TWEOF()) return -1; } +#endif return 0; } @@ -1404,8 +1413,10 @@ int twrpTar::closeTar() { #endif } else { +#ifndef BUILD_TWRPTAR_MAIN if (!twadbbu::Write_TWEOF()) return -1; +#endif } if (input_fd >= 0) close(input_fd); -- cgit v1.2.3