diff options
author | Alexander Tkachev | 2019-07-24 19:12:14 +0700 |
---|---|---|
committer | Matan Bareket | 2019-07-30 14:51:41 -0400 |
commit | e7ca2b8db02aee7f4893964f13f2f708d0a3b695 (patch) | |
tree | bbc6328e0500790f0fc175af723e4b6a86ac1626 | |
parent | 7fc6477ce2d1001ab5111a16d2a6b408951a0b59 (diff) | |
download | scummvm-rg350-e7ca2b8db02aee7f4893964f13f2f708d0a3b695.tar.gz scummvm-rg350-e7ca2b8db02aee7f4893964f13f2f708d0a3b695.tar.bz2 scummvm-rg350-e7ca2b8db02aee7f4893964f13f2f708d0a3b695.zip |
CLOUD: Ignore hidden files in sync/download
In PR#1754 we've discussed and decided to ignore hidden (having a name
starting with '.') files while syncing saves or downloading game files.
This commit adds a CloudManager method to test whether file should be
ignored, and this method could be extended later if we need to ignore
some other specific file names.
-rw-r--r-- | backends/cloud/cloudmanager.cpp | 7 | ||||
-rw-r--r-- | backends/cloud/cloudmanager.h | 3 | ||||
-rw-r--r-- | backends/cloud/folderdownloadrequest.cpp | 4 | ||||
-rw-r--r-- | backends/cloud/savessyncrequest.cpp | 4 |
4 files changed, 15 insertions, 3 deletions
diff --git a/backends/cloud/cloudmanager.cpp b/backends/cloud/cloudmanager.cpp index 432a63b040..a3e9856455 100644 --- a/backends/cloud/cloudmanager.cpp +++ b/backends/cloud/cloudmanager.cpp @@ -358,6 +358,13 @@ Common::String CloudManager::savesDirectoryPath() { return ""; } +bool CloudManager::canSyncFilename(const Common::String &filename) const { + if (filename == "" || filename[0] == '.') + return false; + + return true; +} + SavesSyncRequest *CloudManager::syncSaves(Storage::BoolCallback callback, Networking::ErrorCallback errorCallback) { Storage *storage = getCurrentStorage(); if (storage) { diff --git a/backends/cloud/cloudmanager.h b/backends/cloud/cloudmanager.h index 131af9bb8f..ebcc6ea5cf 100644 --- a/backends/cloud/cloudmanager.h +++ b/backends/cloud/cloudmanager.h @@ -227,6 +227,9 @@ public: /** Returns storage's saves directory path with the trailing slash. */ Common::String savesDirectoryPath(); + /** Returns whether given filename could be uploaded to or downloaded from storage. */ + bool canSyncFilename(const Common::String &filename) const; + /** * Starts saves syncing process in currently active storage if there is any. */ diff --git a/backends/cloud/folderdownloadrequest.cpp b/backends/cloud/folderdownloadrequest.cpp index 3d31beba4b..c3b9eece87 100644 --- a/backends/cloud/folderdownloadrequest.cpp +++ b/backends/cloud/folderdownloadrequest.cpp @@ -26,6 +26,7 @@ #include "common/debug.h" #include "gui/downloaddialog.h" #include <backends/networking/curl/connectionmanager.h> +#include "cloudmanager.h" namespace Cloud { @@ -73,8 +74,9 @@ void FolderDownloadRequest::directoryListedCallback(Storage::ListDirectoryRespon // remove all directories // non-empty directories would be created by DumpFile, and empty ones are just ignored + // also skip all hidden files (with names starting with '.') or with other names that are forbidden to sync in CloudManager for (Common::Array<StorageFile>::iterator i = _pendingFiles.begin(); i != _pendingFiles.end();) - if (i->isDirectory()) + if (i->isDirectory() || !CloudMan.canSyncFilename(i->name())) _pendingFiles.erase(i); else { _totalBytes += i->size(); diff --git a/backends/cloud/savessyncrequest.cpp b/backends/cloud/savessyncrequest.cpp index ab455c63a2..3a581005c6 100644 --- a/backends/cloud/savessyncrequest.cpp +++ b/backends/cloud/savessyncrequest.cpp @@ -96,7 +96,7 @@ void SavesSyncRequest::directoryListedCallback(Storage::ListDirectoryResponse re if (file.isDirectory()) continue; totalSize += file.size(); - if (file.name() == DefaultSaveFileManager::TIMESTAMPS_FILENAME) + if (file.name() == DefaultSaveFileManager::TIMESTAMPS_FILENAME || !CloudMan.canSyncFilename(file.name())) continue; Common::String name = file.name(); @@ -129,7 +129,7 @@ void SavesSyncRequest::directoryListedCallback(Storage::ListDirectoryResponse re //upload files which are unavailable in cloud for (Common::HashMap<Common::String, bool>::iterator i = localFileNotAvailableInCloud.begin(); i != localFileNotAvailableInCloud.end(); ++i) { - if (i->_key == DefaultSaveFileManager::TIMESTAMPS_FILENAME) + if (i->_key == DefaultSaveFileManager::TIMESTAMPS_FILENAME || !CloudMan.canSyncFilename(i->_key)) continue; if (i->_value) { _filesToUpload.push_back(i->_key); |