Skip to content

Commit

Permalink
fix coverity defects
Browse files Browse the repository at this point in the history
  • Loading branch information
pit-ray committed Jan 14, 2024
1 parent 8d12542 commit d718ba2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/core/autocmd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <windows.h>

#include <memory>
#include <stdexcept>
#include <string>
#include <unordered_map>

Expand Down
29 changes: 17 additions & 12 deletions src/gui/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <sstream>
#include <string>

#include "bind/proc/execute.hpp"
#include "core/errlogger.hpp"
#include "core/path.hpp"
#include "core/settable.hpp"
Expand Down Expand Up @@ -123,12 +122,12 @@ namespace vind
tempdir = core::replace_path_magic(tempdir) ;

util::create_process(
tempdir,
"curl",
util::concat_args(
"-H", "@{\"Accept\"=\"application/vnd.github.v3+json\"}",
"\"https://api.github.com/repos/pit-ray/win-vind/releases/latest\"",
"-o", g_release_cache_name), false) ;
tempdir,
"curl.exe",
util::concat_args(
"-H", "@{\"Accept\"=\"application/vnd.github+json\"}",
"\"https://api.github.com/repos/pit-ray/win-vind/releases/latest\"",
"-o", g_release_cache_name), false) ;
const auto json_path = tempdir / g_release_cache_name ;

using namespace std::chrono ;
Expand All @@ -144,7 +143,13 @@ namespace vind

Sleep(500) ;

if(system_clock::now() - start > 30s) { //timeout
if(system_clock::now() - start >
#if defined(DEBUG)
1s
#else
30s
#endif
) { //timeout
break ;
}
}
Expand All @@ -166,6 +171,7 @@ namespace vind
} ;

if(!ifs.is_open()) {
util::shell_execute("https://github.com/pit-ray/win-vind/releases/latest") ;
insert_message(wxT("Could not connect to github.com")) ;
}
else {
Expand Down Expand Up @@ -244,7 +250,7 @@ namespace vind

Bind(wxEVT_HTML_LINK_CLICKED, [](wxHtmlLinkEvent& e) {
auto url = e.GetLinkInfo().GetHref().ToStdString() ;
bind::Execute::sprocess(1, url) ;
util::shell_execute(url) ;
}, UPDATE_NOTES) ;

root->Add(body, flags) ;
Expand Down Expand Up @@ -289,7 +295,7 @@ namespace vind
Sleep(500) ;
std::ifstream check(dl_filepath) ;
if(check.is_open()) {
bind::Execute::sprocess(1, dl_filepath.u8string()) ;
util::shell_execute(dl_filepath.u8string()) ;
parent->Destroy() ; // exit win-vind for update
break ;
}
Expand All @@ -302,8 +308,7 @@ namespace vind
}
}
catch(const nlohmann::json::exception&) {
bind::Execute::sprocess(
1, "https://github.com/pit-ray/win-vind/releases/latest") ;
util::shell_execute("https://github.com/pit-ray/win-vind/releases/latest") ;
}
}, wxID_OK) ;
}
Expand Down

0 comments on commit d718ba2

Please sign in to comment.