From 4ff846e5cd7715a3750dcc4a7239ebee6eb38b61 Mon Sep 17 00:00:00 2001 From: loki-47-6F-64 Date: Thu, 4 Aug 2022 23:04:37 +0200 Subject: [PATCH] Add a whitelist and blacklist for cloud saves --- include/config.h | 4 ++++ include/downloader.h | 2 ++ main.cpp | 5 ++++- src/downloader.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/include/config.h b/include/config.h index 4030386..f97f07a 100644 --- a/include/config.h +++ b/include/config.h @@ -296,6 +296,10 @@ class Config Blacklist blacklist; Blacklist ignorelist; Blacklist gamehasdlc; + + std::vector cloudWhiteList; + std::vector cloudBlackList; + std::string sGameHasDLCList; // Integers diff --git a/include/downloader.h b/include/downloader.h index 53af972..45dddcd 100644 --- a/include/downloader.h +++ b/include/downloader.h @@ -101,10 +101,12 @@ class Downloader void clearUpdateNotifications(); void repair(); void download(); + void downloadCloudSaves(const std::string& product_id, int build_index = -1); void downloadCloudSavesById(const std::string& product_id, int build_index = -1); void uploadCloudSaves(const std::string& product_id, int build_index = -1); void uploadCloudSavesById(const std::string& product_id, int build_index = -1); + void checkOrphans(); void checkStatus(); void updateCache(); diff --git a/main.cpp b/main.cpp index bdd9553..e153c05 100644 --- a/main.cpp +++ b/main.cpp @@ -229,6 +229,10 @@ int main(int argc, char *argv[]) ("cacert", bpo::value(&Globals::globalConfig.curlConf.sCACertPath)->default_value(""), "Path to CA certificate bundle in PEM format") ("respect-umask", bpo::value(&Globals::globalConfig.bRespectUmask)->zero_tokens()->default_value(false), "Do not adjust permissions of sensitive files") ("user-agent", bpo::value(&Globals::globalConfig.curlConf.sUserAgent)->default_value(DEFAULT_USER_AGENT), "Set user agent") + + ("wine-prefix", bpo::value(&Globals::globalConfig.dirConf.sWinePrefix)->default_value("."), "Set wineprefix directory") + ("cloud-whitelist", bpo::value>(&Globals::globalConfig.cloudWhiteList)->multitoken(), "Include this list of cloud saves, by default all cloud saves are included\n Example: --cloud-whitelist saves/AutoSave-0 saves/AutoSave-1/screenshot.png") + ("cloud-blacklist", bpo::value>(&Globals::globalConfig.cloudBlackList)->multitoken(), "Exclude this list of cloud saves\n Example: --cloud-blacklist saves/AutoSave-0 saves/AutoSave-1/screenshot.png") #ifdef USE_QT_GUI_LOGIN ("enable-login-gui", bpo::value(&Globals::globalConfig.bEnableLoginGUI)->zero_tokens()->default_value(false), "Enable login GUI when encountering reCAPTCHA on login form") #endif @@ -238,7 +242,6 @@ int main(int argc, char *argv[]) // Commandline options (config file) options_cli_cfg.add_options() ("directory", bpo::value(&Globals::globalConfig.dirConf.sDirectory)->default_value("."), "Set download directory") - ("wine-prefix", bpo::value(&Globals::globalConfig.dirConf.sWinePrefix)->default_value("."), "Set wineprefix directory") ("limit-rate", bpo::value(&Globals::globalConfig.curlConf.iDownloadRate)->default_value(0), "Limit download rate to value in kB\n0 = unlimited") ("xml-directory", bpo::value(&Globals::globalConfig.sXMLDirectory), "Set directory for GOG XML files") ("chunk-size", bpo::value(&Globals::globalConfig.iChunkSize)->default_value(10), "Chunk size (in MB) when creating XML") diff --git a/src/downloader.cpp b/src/downloader.cpp index 65b50b4..5588b53 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -83,6 +83,31 @@ void dirForEach(const std::string &location, std::functionpath().string() }; @@ -4904,10 +4939,16 @@ void Downloader::galaxyShowLocalCloudSavesById(const std::string& product_id, in } dirForEach(location, [&](boost::filesystem::directory_iterator file) { + auto path = (name / boost::filesystem::relative(*file, location)).string(); + + if(!whitelisted(path)) { + return; + } + cloudSaveFile csf { boost::posix_time::from_time_t(boost::filesystem::last_write_time(*file) - 1), boost::filesystem::file_size(*file), - (name / boost::filesystem::relative(*file, location)).string(), + std::move(path), file->path().string() };