summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libtar/wrapper.c12
-rw-r--r--partition.cpp2
-rw-r--r--twrpTar.cpp100
-rw-r--r--twrpTar.hpp6
4 files changed, 72 insertions, 48 deletions
diff --git a/libtar/wrapper.c b/libtar/wrapper.c
index 0673244f5..dab7e0076 100644
--- a/libtar/wrapper.c
+++ b/libtar/wrapper.c
@@ -153,10 +153,12 @@ tar_append_tree(TAR *t, char *realdir, char *savedir, char *exclude)
if (exclude) {
int omit = 0;
for (i = 0; i < (n_spaces+1); i++) {
- if (dent->d_name == excluded[i]) {
- printf(" excluding '%s'\n", excluded[i]);
- omit = 1;
- break;
+ if (excluded[i] != NULL) {
+ if (strcmp(dent->d_name, excluded[i]) == 0 || strcmp(excluded[i], realdir) == 0) {
+ printf(" excluding '%s'\n", excluded[i]);
+ omit = 1;
+ break;
+ }
}
}
if (omit)
@@ -179,7 +181,7 @@ tar_append_tree(TAR *t, char *realdir, char *savedir, char *exclude)
return -1;
continue;
}
- }
+ }
closedir(dp);
free(excluded);
diff --git a/partition.cpp b/partition.cpp
index e02def032..444eb4bc5 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -1452,6 +1452,8 @@ bool TWPartition::Backup_Tar(string backup_folder) {
DataManager::GetValue(TW_USE_COMPRESSION_VAR, use_compression);
tar.use_compression = use_compression;
+ //exclude Google Music Cache
+ tar.setexcl("/data/data/com.google.android.music/files");
#ifndef TW_EXCLUDE_ENCRYPTED_BACKUPS
DataManager::GetValue("tw_encrypt_backup", use_encryption);
if (use_encryption && Can_Encrypt_Backup) {
diff --git a/twrpTar.cpp b/twrpTar.cpp
index 2b8cd7dc4..5a9340a25 100644
--- a/twrpTar.cpp
+++ b/twrpTar.cpp
@@ -66,7 +66,7 @@ void twrpTar::setdir(string dir) {
}
void twrpTar::setexcl(string exclude) {
- tarexclude = exclude;
+ tarexclude.push_back(exclude);
}
int twrpTar::createTarFork() {
@@ -522,8 +522,9 @@ int twrpTar::Generate_Multiple_Archives(string Path) {
break;
}
}
- if (skip)
+ if (skip) {
continue;
+ }
}
FileName = Path + "/";
FileName += de->d_name;
@@ -550,35 +551,40 @@ int twrpTar::Generate_Multiple_Archives(string Path) {
else if (de->d_type == DT_REG || de->d_type == DT_LNK)
{
stat(FileName.c_str(), &st);
-
- if (Archive_Current_Size != 0 && Archive_Current_Size + st.st_size > MAX_ARCHIVE_SIZE) {
- LOGINFO("Closing tar '%s', ", tarfn.c_str());
- closeTar();
- if (TWFunc::Get_File_Size(tarfn) == 0) {
- LOGERR("Backup file size for '%s' is 0 bytes.\n", tarfn.c_str());
- return -1;
- }
- Archive_File_Count++;
- if (Archive_File_Count > 999) {
- LOGERR("Archive count is too large!\n");
- return -1;
+ if (de->d_type != DT_LNK) {
+ if (Archive_Current_Size != 0 && Archive_Current_Size + st.st_size > MAX_ARCHIVE_SIZE) {
+ LOGINFO("Closing tar '%s', ", tarfn.c_str());
+ closeTar();
+ if (TWFunc::Get_File_Size(tarfn) == 0) {
+ LOGERR("Backup file size for '%s' is 0 bytes.\n", tarfn.c_str());
+ return -1;
+ }
+ Archive_File_Count++;
+ if (Archive_File_Count > 999) {
+ LOGERR("Archive count is too large!\n");
+ return -1;
+ }
+ string temp = basefn + "%03i";
+ sprintf(actual_filename, temp.c_str(), Archive_File_Count);
+ tarfn = actual_filename;
+ Archive_Current_Size = 0;
+ LOGINFO("Creating tar '%s'\n", tarfn.c_str());
+ gui_print("Creating archive %i...\n", Archive_File_Count + 1);
+ if (createTar() != 0)
+ return -1;
}
- string temp = basefn + "%03i";
- sprintf(actual_filename, temp.c_str(), Archive_File_Count);
- tarfn = actual_filename;
- Archive_Current_Size = 0;
- LOGINFO("Creating tar '%s'\n", tarfn.c_str());
- gui_print("Creating archive %i...\n", Archive_File_Count + 1);
- if (createTar() != 0)
- return -1;
}
LOGINFO("Adding file: '%s'... ", FileName.c_str());
if (addFile(FileName, true) < 0)
return -1;
- Archive_Current_Size += st.st_size;
+ if (de->d_type != DT_LNK) {
+ Archive_Current_Size += st.st_size;
+ }
LOGINFO("added successfully, archive size: %llu\n", Archive_Current_Size);
- if (st.st_size > 2147483648LL)
- LOGERR("There is a file that is larger than 2GB in the file system\n'%s'\nThis file may not restore properly\n", FileName.c_str());
+ if (de->d_type != DT_LNK) {
+ if (st.st_size > 2147483648LL)
+ LOGERR("There is a file that is larger than 2GB in the file system\n'%s'\nThis file may not restore properly\n", FileName.c_str());
+ }
}
}
closedir(d);
@@ -589,14 +595,21 @@ int twrpTar::Split_Archive()
{
string temp = tarfn + "%03i";
char actual_filename[255];
+ string tarsplit;
basefn = tarfn;
Archive_File_Count = 0;
Archive_Current_Size = 0;
sprintf(actual_filename, temp.c_str(), Archive_File_Count);
tarfn = actual_filename;
+
+ for (int i = 0; i < tarexclude.size(); ++i) {
+ tarsplit = tarexclude[i];
+ tarsplit += " ";
+ }
+
if (!tarexclude.empty())
- split = TWFunc::split_string(tarexclude, ' ', true);
+ split = TWFunc::split_string(tarsplit, ' ', true);
createTar();
DataManager::GetValue(TW_HAS_DATA_MEDIA, has_data_media);
gui_print("Creating archive 1...\n");
@@ -659,17 +672,23 @@ int twrpTar::extract() {
int twrpTar::tarDirs(bool include_root) {
DIR* d;
string mainfolder = tardir + "/", subfolder;
+ string tarsplit;
char buf[PATH_MAX], charTarPath[PATH_MAX];
-
- char excl[1024];
+ string excl;
string::size_type i;
bool skip;
+ //set exclude directories for libtar
+ for (int i = 0; i < tarexclude.size(); ++i) {
+ excl += tarexclude.at(i);
+ tarsplit = tarexclude.at(i);
+ excl += " ";
+ tarsplit += " ";
+ }
d = opendir(tardir.c_str());
if (d != NULL) {
- if (!tarexclude.empty()) {
- strcpy(excl, tarexclude.c_str());
- split = TWFunc::split_string(tarexclude, ' ', true);
+ if (!tarsplit.empty()) {
+ split = TWFunc::split_string(tarsplit, ' ', true);
}
struct dirent* de;
while ((de = readdir(d)) != NULL) {
@@ -689,8 +708,9 @@ int twrpTar::tarDirs(bool include_root) {
break;
}
}
- if (skip)
+ if (skip) {
continue;
+ }
}
subfolder = mainfolder;
@@ -707,7 +727,7 @@ int twrpTar::tarDirs(bool include_root) {
if (include_root) {
charTarPath[0] = NULL;
LOGINFO("tar_append_tree '%s' as NULL\n", buf, charTarPath);
- if (tar_append_tree(t, buf, NULL, excl) != 0) {
+ if (tar_append_tree(t, buf, NULL, &excl[0]) != 0) {
LOGERR("Error appending '%s' to tar archive '%s'\n", buf, tarfn.c_str());
return -1;
}
@@ -715,7 +735,7 @@ int twrpTar::tarDirs(bool include_root) {
string temp = Strip_Root_Dir(buf);
strcpy(charTarPath, temp.c_str());
LOGINFO("tar_append_tree '%s' as '%s'\n", buf, charTarPath);
- if (tar_append_tree(t, buf, charTarPath, excl) != 0) {
+ if (tar_append_tree(t, buf, charTarPath, &excl[0]) != 0) {
LOGERR("Error appending '%s' to tar archive '%s'\n", buf, tarfn.c_str());
return -1;
}
@@ -879,7 +899,7 @@ int twrpTar::createTar() {
return -1;
}
pigz_pid = fork();
-
+
if (pigz_pid < 0) {
LOGERR("pigz fork() failed\n");
for (i = 0; i < 4; i++)
@@ -902,7 +922,7 @@ int twrpTar::createTar() {
} else {
// Parent
oaes_pid = fork();
-
+
if (oaes_pid < 0) {
LOGERR("openaes fork() failed\n");
for (i = 0; i < 4; i++)
@@ -955,7 +975,7 @@ int twrpTar::createTar() {
return -1;
}
pigz_pid = fork();
-
+
if (pigz_pid < 0) {
LOGERR("fork() failed\n");
close(pigzfd[0]);
@@ -996,7 +1016,7 @@ int twrpTar::createTar() {
int oaesfd[2];
pipe(oaesfd);
oaes_pid = fork();
-
+
if (oaes_pid < 0) {
LOGERR("fork() failed\n");
close(oaesfd[0]);
@@ -1059,7 +1079,7 @@ int twrpTar::openTar() {
return -1;
}
oaes_pid = fork();
-
+
if (oaes_pid < 0) {
LOGERR("pigz fork() failed\n");
for (i = 0; i < 4; i++)
@@ -1089,7 +1109,7 @@ int twrpTar::openTar() {
} else {
// Parent
pigz_pid = fork();
-
+
if (pigz_pid < 0) {
LOGERR("openaes fork() failed\n");
for (i = 0; i < 4; i++)
diff --git a/twrpTar.hpp b/twrpTar.hpp
index 88eedb5c2..9128ba0df 100644
--- a/twrpTar.hpp
+++ b/twrpTar.hpp
@@ -51,7 +51,7 @@ public:
void setfn(string fn);
void setdir(string dir);
unsigned long long uncompressedSize();
-
+
public:
int use_encryption;
int userdata_encryption;
@@ -91,10 +91,10 @@ private:
string tardir;
string tarfn;
string basefn;
- string tarexclude;
+ vector <string> tarexclude;
vector<string> split;
std::vector<TarListStruct> *ItemList;
int thread_id;
-};
+};