From 5d212d6a22c0257a73f04cbda17a0f663524c8de Mon Sep 17 00:00:00 2001 From: Xun Li Date: Fri, 3 Mar 2017 13:46:07 -0600 Subject: [PATCH] Update logic of autoupdate to allow create directory when upload --- .gitignore | 1 + BuildTools/centos/GNUmakefile | 1 + DialogTools/AutoUpdateDlg.cpp | 51 ++++++++++++++++++++++------------- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index b002cb35c..f86783b81 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ BuildTools/centos/libraries/ BuildTools/centos/temp/ +BuildTools/centos/build/ BuildTools/ubuntu/libraries/ BuildTools/ubuntu/temp/ diff --git a/BuildTools/centos/GNUmakefile b/BuildTools/centos/GNUmakefile index 120f0e1cc..2d5feba8c 100644 --- a/BuildTools/centos/GNUmakefile +++ b/BuildTools/centos/GNUmakefile @@ -57,6 +57,7 @@ build-geoda-mac: chmod +x build/run.sh cp GeoDa.desktop build/GeoDa.desktop cp $(GeoDa_ROOT)/BuildTools/CommonDistFiles/cache.sqlite build/web_plugins/cache.sqlite + cp -rf $(GeoDa_ROOT)/BuildTools/CommonDistFiles/web_plugins/* build/web_plugins/ cp $(GeoDa_ROOT)/BuildTools/CommonDistFiles/GeoDa.png build/GeoDa.png cp $(GeoDa_ROOT)/rc/data_viewer_dialogs.xrc build/Resources cp $(GeoDa_ROOT)/rc/dialogs.xrc build/Resources diff --git a/DialogTools/AutoUpdateDlg.cpp b/DialogTools/AutoUpdateDlg.cpp index e24668c9e..00af4f06f 100644 --- a/DialogTools/AutoUpdateDlg.cpp +++ b/DialogTools/AutoUpdateDlg.cpp @@ -374,32 +374,45 @@ void AutoUpdateDlg::OnOkClick( wxCommandEvent& event ) wxString file_size = lines.front(); lines.pop(); - file_name = exeDir + file_name; - wxString update_file_name = file_name + ".update"; - wxString backup_file_name = file_name + ".backup"; int size = wxAtoi(file_size); - wxRemoveFile(backup_file_name); - wxRemoveFile(update_file_name); - - if (DownloadUrl(file_url.mb_str(), update_file_name.mb_str())){ - // check file size - wxFileName updateFile(update_file_name); - wxULongLong update_size = updateFile.GetSize(); + if (size == 0) { + // create a directory using file_name + wxString new_dir = exeDir + file_name; + if (!wxDirExists(new_dir)) { + if (!wxMkdir(new_dir)){ + success = false; + break; + } + } - if (update_size != size ) - throw GdaException(""); + } else { + file_name = exeDir + file_name; + wxString update_file_name = file_name + ".update"; + wxString backup_file_name = file_name + ".backup"; - // replace the old file - wxRenameFile(file_name, backup_file_name); - wxRenameFile(update_file_name, file_name); + wxRemoveFile(backup_file_name); + wxRemoveFile(update_file_name); - wxRemoveFile(backup_file_name); - wxRemoveFile(update_file_name); + if (DownloadUrl(file_url.mb_str(), update_file_name.mb_str())){ + // check file size + wxFileName updateFile(update_file_name); + wxULongLong update_size = updateFile.GetSize(); + + if (update_size != size ) + throw GdaException(""); + + // replace the old file + wxRenameFile(file_name, backup_file_name); + wxRenameFile(update_file_name, file_name); + + wxRemoveFile(backup_file_name); + wxRemoveFile(update_file_name); - success = true; + success = true; + } + progressDlg.Update(current_job++); } - progressDlg.Update(current_job++); } } } catch(...) {