From 6f35fc42721895be70c6c21f87eb9a75693ff168 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sat, 28 May 2016 20:40:20 +0600 Subject: CLOUD: Add OneDriveStorage::downloadFolder() Just uses FolderDownloadRequest the way DropboxStorage does. --- backends/cloud/onedrive/onedrivestorage.cpp | 8 +++++++- backends/cloud/onedrive/onedrivestorage.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'backends/cloud/onedrive') diff --git a/backends/cloud/onedrive/onedrivestorage.cpp b/backends/cloud/onedrive/onedrivestorage.cpp index d14379393b..c924dbf093 100644 --- a/backends/cloud/onedrive/onedrivestorage.cpp +++ b/backends/cloud/onedrive/onedrivestorage.cpp @@ -25,6 +25,7 @@ #include "backends/cloud/onedrive/onedrivetokenrefresher.h" #include "backends/cloud/onedrive/onedrivelistdirectoryrequest.h" #include "backends/cloud/downloadrequest.h" +#include "backends/cloud/folderdownloadrequest.h" #include "backends/networking/curl/connectionmanager.h" #include "backends/networking/curl/curljsonrequest.h" #include "common/cloudmanager.h" @@ -187,6 +188,11 @@ Networking::Request *OneDriveStorage::download(Common::String remotePath, Common return ConnMan.addRequest(new DownloadRequest(this, callback, remotePath, f)); } +/** Returns Common::Array with list of files, which were not downloaded. */ +Networking::Request *OneDriveStorage::downloadFolder(Common::String remotePath, Common::String localPath, FileArrayCallback callback, bool recursive) { + return ConnMan.addRequest(new FolderDownloadRequest(this, callback, remotePath, localPath, recursive)); +} + void OneDriveStorage::fileDownloaded(BoolResponse pair) { if (pair.value) debug("file downloaded!"); else debug("download failed!"); @@ -207,7 +213,7 @@ Networking::Request *OneDriveStorage::syncSaves(BoolCallback callback) { request->addHeader("Authorization: bearer " + _token); return ConnMan.addRequest(request); */ - return listDirectory("subfolder", new Common::Callback(this, &OneDriveStorage::printFiles), true); + return downloadFolder("subfolder", "local/onedrive/subfolder_downloaded", new Common::Callback(this, &OneDriveStorage::printFiles), false); } OneDriveStorage *OneDriveStorage::loadFromConfig(Common::String keyPrefix) { diff --git a/backends/cloud/onedrive/onedrivestorage.h b/backends/cloud/onedrive/onedrivestorage.h index c9a32a802f..674d13634d 100644 --- a/backends/cloud/onedrive/onedrivestorage.h +++ b/backends/cloud/onedrive/onedrivestorage.h @@ -85,6 +85,9 @@ public: /** Calls the callback when finished. */ virtual Networking::Request *download(Common::String remotePath, Common::String localPath, BoolCallback callback); + /** Returns Common::Array with list of files, which were not downloaded. */ + virtual Networking::Request *downloadFolder(Common::String remotePath, Common::String localPath, FileArrayCallback callback, bool recursive = false); + /** Calls the callback when finished. */ virtual Networking::Request *remove(Common::String path, BoolCallback callback) { return nullptr; } //TODO -- cgit v1.2.3