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
diff --git a/partition.cpp b/partition.cpp
index 3f2374a..78b11ec 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -43,7 +43,7 @@
#include "twrp-functions.hpp"
#include "twrpDigest.hpp"
#include "twrpTar.hpp"
-#include "twrpDU.hpp"
+#include "exclude.hpp"
#include "infomanager.hpp"
#include "set_metadata.h"
#include "gui/gui.hpp"
@@ -866,9 +866,13 @@
}
DataManager::SetValue("tw_has_internal", 1);
DataManager::SetValue("tw_has_data_media", 1);
- du.add_absolute_dir(Mount_Point + "/misc/vold");
- du.add_absolute_dir(Mount_Point + "/.layout_version");
- du.add_absolute_dir(Mount_Point + "/system/storage.xml");
+ backup_exclusions.add_absolute_dir("/data/data/com.google.android.music/files");
+ backup_exclusions.add_absolute_dir(Mount_Point + "/misc/vold");
+ wipe_exclusions.add_absolute_dir(Mount_Point + "/misc/vold");
+ backup_exclusions.add_absolute_dir(Mount_Point + "/.layout_version");
+ wipe_exclusions.add_absolute_dir(Mount_Point + "/.layout_version");
+ backup_exclusions.add_absolute_dir(Mount_Point + "/system/storage.xml");
+ wipe_exclusions.add_absolute_dir(Mount_Point + "/system/storage.xml");
} else {
if (Mount(true) && TWFunc::Path_Exists(Mount_Point + "/media/0")) {
Storage_Path = Mount_Point + "/media/0";
@@ -876,7 +880,8 @@
UnMount(true);
}
}
- du.add_absolute_dir(Mount_Point + "/media");
+ backup_exclusions.add_absolute_dir(Mount_Point + "/media");
+ wipe_exclusions.add_absolute_dir(Mount_Point + "/media");
}
void TWPartition::Find_Real_Block_Device(string& Block, bool Display_Error) {
@@ -2113,7 +2118,7 @@
dir = parent;
dir.append(de->d_name);
- if (du.check_skip_dirs(dir)) {
+ if (wipe_exclusions.check_skip_dirs(dir)) {
LOGINFO("skipped '%s'\n", dir.c_str());
continue;
}
@@ -2168,6 +2173,7 @@
Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName;
tar.has_data_media = Has_Data_Media;
tar.part_settings = part_settings;
+ tar.backup_exclusions = &backup_exclusions;
tar.setdir(Backup_Path);
tar.setfn(Full_FileName);
tar.setsize(Backup_Size);
@@ -2490,7 +2496,7 @@
if (Has_Data_Media) {
if (Mount(Display_Error)) {
unsigned long long data_media_used, actual_data;
- Used = du.Get_Folder_Size(Mount_Point);
+ Used = backup_exclusions.Get_Folder_Size(Mount_Point);
Backup_Size = Used;
int bak = (int)(Used / 1048576LLU);
int fre = (int)(Free / 1048576LLU);
@@ -2502,7 +2508,7 @@
}
} else if (Has_Android_Secure) {
if (Mount(Display_Error))
- Backup_Size = du.Get_Folder_Size(Backup_Path);
+ Backup_Size = backup_exclusions.Get_Folder_Size(Backup_Path);
else {
if (!Was_Already_Mounted)
UnMount(false);