From 80b5d41eb6ede259bacca1a66dab2805d3a76694 Mon Sep 17 00:00:00 2001 From: Matthew Howle Date: Wed, 8 Jul 2020 19:07:56 -0400 Subject: [PATCH 1/2] Overwrite changelog only when modified --- src/downloader.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/downloader.cpp b/src/downloader.cpp index 6968ab8..81f402a 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -2331,6 +2331,22 @@ void Downloader::saveChangelog(const std::string& changelog, const std::string& } } + // Check if changelog matches current changelog + if (boost::filesystem::exists(filepath)) + { + std::ifstream ifs(filepath); + if (ifs) + { + std::string current_changelog((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); + ifs.close(); + if (changelog == current_changelog) + { + std::cout << "Changelog unchanged. Skipping: " << filepath << std::endl; + return; + } + } + } + std::ofstream ofs(filepath); if (ofs) { From 5cef659e9818d8df6a81ea32844596ee700c3e6c Mon Sep 17 00:00:00 2001 From: Matthew Howle Date: Sun, 20 Sep 2020 00:33:56 -0400 Subject: [PATCH 2/2] Adjust wording to be more precise The variable name "current_changelog" was ambiguous. It could apply to both the newly obtained changelog from GOG and the previously saved changelog on the filesystem. --- src/downloader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/downloader.cpp b/src/downloader.cpp index 81f402a..97212ba 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -2331,15 +2331,15 @@ void Downloader::saveChangelog(const std::string& changelog, const std::string& } } - // Check if changelog matches current changelog + // Check whether the changelog has changed if (boost::filesystem::exists(filepath)) { std::ifstream ifs(filepath); if (ifs) { - std::string current_changelog((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); + std::string existing_changelog((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); ifs.close(); - if (changelog == current_changelog) + if (changelog == existing_changelog) { std::cout << "Changelog unchanged. Skipping: " << filepath << std::endl; return;