From caaa4c5a5d0bce7582cc6611d8bde53fbdb1f2d1 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Tue, 24 May 2016 12:31:27 +0600 Subject: CLOUD: Make DownloadRequest write to local file Tested with .jpg file. Transfer complete, CRC-32 is the same. --- backends/cloud/dropbox/dropboxstorage.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'backends/cloud/dropbox/dropboxstorage.cpp') diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp index 1b6dc1b92f..38ad12d94b 100644 --- a/backends/cloud/dropbox/dropboxstorage.cpp +++ b/backends/cloud/dropbox/dropboxstorage.cpp @@ -30,6 +30,7 @@ #include "common/debug.h" #include "common/json.h" #include +#include namespace Cloud { namespace Dropbox { @@ -100,15 +101,23 @@ Networking::NetworkReadStream *DropboxStorage::streamFile(Common::String path) { return request->execute(); } -void DropboxStorage::download(Common::String path, BoolCallback callback) { - ConnMan.addRequest(new DownloadRequest(callback, streamFile(path))); +void DropboxStorage::download(Common::String remotePath, Common::String localPath, BoolCallback callback) { + Common::DumpFile *f = new Common::DumpFile(); + if (!f->open(localPath)) { + warning("DropboxStorage: unable to open file to download into"); + if (callback) (*callback)(false); + delete f; + return; + } + + ConnMan.addRequest(new DownloadRequest(callback, streamFile(remotePath), f)); } void DropboxStorage::syncSaves(BoolCallback callback) { //this is not the real syncSaves() implementation //"" is root in Dropbox, not "/" //listDirectory("", new Common::Callback >(this, &DropboxStorage::printFiles), true); - download("/notempty.txt", 0); + download("/remote/test.jpg", "local/test.jpg", 0); } void DropboxStorage::info(StorageInfoCallback outerCallback) { -- cgit v1.2.3