Fix (Auto Generate) handling for backup names
Change-Id: I29f3823d03c005fb55a0e0a98818d40bd1eb039d
diff --git a/gui/action.cpp b/gui/action.cpp
index 803d313..711f645 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -1169,9 +1169,8 @@
if (arg == "backup") {
string Backup_Name;
DataManager::GetValue(TW_BACKUP_NAME, Backup_Name);
- string auto_gen = gui_lookup("auto_gen", "(Auto Generate)");
- string curr_date = gui_lookup("curr_date", "(Current Date)");
- if (Backup_Name == "(Auto Generate)" || Backup_Name == "(Current Date)" || Backup_Name == "0" || Backup_Name == "(" || PartitionManager.Check_Backup_Name(true) == 0) {
+ string auto_gen = gui_lookup("auto_generate", "(Auto Generate)");
+ if (Backup_Name == auto_gen || Backup_Name == gui_lookup("curr_date", "(Current Date)") || Backup_Name == "0" || Backup_Name == "(" || PartitionManager.Check_Backup_Name(true) == 0) {
ret = PartitionManager.Run_Backup();
}
else {
diff --git a/gui/pages.cpp b/gui/pages.cpp
index 932be6b..ddf53a9 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -687,6 +687,7 @@
xml_node<>* parent;
xml_node<>* child;
std::string resource_source;
+ int ret = 0;
if (languageFile) {
printf("parsing languageFile\n");
@@ -717,9 +718,10 @@
if (child)
mResources->LoadResources(child, package, resource_source);
else
- return -1;
+ ret = -1;
+ DataManager::SetValue("tw_backup_name", gui_lookup("auto_generate", "(Auto Generate)"));
lang.clear();
- return 0;
+ return ret;
}
int PageSet::Load(ZipArchive* package, char* xmlFile, char* languageFile, char* baseLanguageFile)
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 5dd2ce5..00c4f8f 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -447,7 +447,7 @@
// and -_.{}[]
} else {
if (Display_Error)
- gui_msg(Msg(msg::kError, "backup_name_invalid=Backup name '{1}' contains invalid character: '{1}'")(backup_name)((char)cur_char));
+ gui_msg(Msg(msg::kError, "backup_name_invalid=Backup name '{1}' contains invalid character: '{1}'")(Backup_Name)((char)cur_char));
return -3;
}
}
@@ -682,9 +682,9 @@
DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, Backup_Folder);
DataManager::GetValue(TW_BACKUP_NAME, Backup_Name);
- if (Backup_Name == gui_parse_text("{@current_date}")) {
+ if (Backup_Name == gui_lookup("curr_date", "(Current Date)")) {
Backup_Name = TWFunc::Get_Current_Date();
- } else if (Backup_Name == gui_parse_text("{@auto_generate}") || Backup_Name == "0" || Backup_Name.empty()) {
+ } else if (Backup_Name == gui_lookup("auto_generate", "(Auto Generate)") || Backup_Name == "0" || Backup_Name.empty()) {
TWFunc::Auto_Generate_Backup_Name();
DataManager::GetValue(TW_BACKUP_NAME, Backup_Name);
}