Skip to content

Commit

Permalink
cache fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Skwll committed Jul 18, 2023
1 parent 82ec6a5 commit 07f015a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
configuration:
- Debug
#- Debug
- Release
steps:
- name: Check out files
Expand Down
22 changes: 17 additions & 5 deletions src/client/updater/file_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,30 @@ namespace updater
}

// Create the cache files
std::ofstream cache_file1(CACHE_PATH + "cache.bin");
std::ofstream cache_file2(CACHE_PATH + "data.bin");
std::string cache_file1_path = CACHE_PATH + "cache.bin";
if (!std::filesystem::exists(cache_file1_path))
{
std::ofstream cache_file1(cache_file1_path);
if (cache_file1.fail())
{
throw std::runtime_error("Failed to create cache.bin file!");
}
}

if (cache_file1.fail() || cache_file2.fail())
std::string cache_file2_path = CACHE_PATH + "data.bin";
if (!std::filesystem::exists(cache_file2_path))
{
throw std::runtime_error("Failed to create cache files!");
std::ofstream cache_file2(cache_file2_path);
if (cache_file2.fail())
{
throw std::runtime_error("Failed to create data.bin file!");
}
}
}

void file_updater::run() const
{
create_cache_files();
auto data = utils::http::get_data(OLD_DLL);
std::string url_ext_dll_hash = data ? get_hash(*data) : "";

Expand All @@ -190,7 +203,6 @@ namespace updater
if (!outdated_files.empty())
{
this->update_files(outdated_files);
create_cache_files();
std::this_thread::sleep_for(1s);
}
}
Expand Down

0 comments on commit 07f015a

Please sign in to comment.