Skip to content

Commit

Permalink
Merge branch 'app-update' of https://github.com/zimbora/DSW into tKYA…
Browse files Browse the repository at this point in the history
…N2-develop
  • Loading branch information
zimbora committed Jun 7, 2024
2 parents f33cc83 + 4d0c06c commit 904845d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
40 changes: 20 additions & 20 deletions src/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,37 +69,37 @@ bool GrantWritePermissions(const fs::path& path) {
return false;
}

std::string File_SHA256(const std::string& path)
{
std::ifstream fp(path, std::ios::in | std::ios::binary);
std::string File_SHA256(const std::string& path){
std::ifstream fp(path, std::ios::in | std::ios::binary);

if (not fp.good()) {
if (not fp.good()) {
LogPrintf("-SHA256::%s: Error: %s, Cannot open: %s\n",__func__, std::strerror(errno),path);
return "";
}
}

constexpr const std::size_t buffer_size { 1 << 12 };
char buffer[buffer_size];
constexpr const std::size_t buffer_size { 1 << 12 };
char buffer[buffer_size];

unsigned char hash[SHA256_DIGEST_LENGTH] = { 0 };
unsigned char hash[SHA256_DIGEST_LENGTH] = { 0 };

SHA256_CTX ctx;
SHA256_Init(&ctx);
SHA256_CTX ctx;
SHA256_Init(&ctx);

while (fp.good()) {
while (fp.good()) {
fp.read(buffer, buffer_size);
SHA256_Update(&ctx, buffer, fp.gcount());
}
}

SHA256_Final(hash, &ctx);
fp.close();
SHA256_Final(hash, &ctx);
fp.close();

std::ostringstream os;
os << std::hex << std::setfill('0');
std::ostringstream os;
os << std::hex << std::setfill('0');

for (int i = 0; i < SHA256_DIGEST_LENGTH; ++i) {
for (int i = 0; i < SHA256_DIGEST_LENGTH; ++i) {
os << std::setw(2) << static_cast<unsigned int>(hash[i]);
}
}

return os.str();
}
return os.str();
}
4 changes: 2 additions & 2 deletions src/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ bool CUpdate::Start(const std::string& execName){
// --- Check if current version is lower than remote version ---
LogPrintf("-Update: current version: %d\n",CLIENT_VERSION);
LogPrintf("-Update: remote version: %d\n",version);
if(false && version <= CLIENT_VERSION){
if(version <= CLIENT_VERSION){
LogPrintf("-Update: current version is the most recent\n");
uiInterface.InitMessage(_("Current version is the most recent"));
return false;
Expand Down Expand Up @@ -403,7 +403,7 @@ bool CUpdate::Start(const std::string& execName){
}
// --- ----- ---

if(false && !ready){
if(!ready){
LogPrintf("-Update: Executable file not found");
if (fs::exists(appPath))
fs::remove(appPath);
Expand Down

0 comments on commit 904845d

Please sign in to comment.