Skip to content

Commit

Permalink
Update logic of autoupdate to allow create directory when upload
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 committed Mar 3, 2017
1 parent 2de4bb8 commit 5d212d6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

BuildTools/centos/libraries/
BuildTools/centos/temp/
BuildTools/centos/build/

BuildTools/ubuntu/libraries/
BuildTools/ubuntu/temp/
Expand Down
1 change: 1 addition & 0 deletions BuildTools/centos/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 32 additions & 19 deletions DialogTools/AutoUpdateDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(...) {
Expand Down

0 comments on commit 5d212d6

Please sign in to comment.