summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2017-05-09 23:04:10 +0300
committeraunsane <aunsane@gmail.com>2017-05-09 23:04:31 +0300
commitae52dee4a7b2e108dc260d52ce0e0bde78474ac9 (patch)
tree4f4686a83ff901e136765f321a8550085e03ef5c /plugins
parentaf8a9e244150d0fe2e584a23ed9a5432c58f8e56 (diff)
CloudFile: fix upload
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CloudFile/src/Services/dropbox_service.cpp9
-rw-r--r--plugins/CloudFile/src/Services/dropbox_service.h4
-rw-r--r--plugins/CloudFile/src/Services/google_api.h2
-rw-r--r--plugins/CloudFile/src/Services/google_service.cpp3
-rw-r--r--plugins/CloudFile/src/Services/microsoft_service.cpp5
-rw-r--r--plugins/CloudFile/src/Services/yandex_service.cpp3
6 files changed, 11 insertions, 15 deletions
diff --git a/plugins/CloudFile/src/Services/dropbox_service.cpp b/plugins/CloudFile/src/Services/dropbox_service.cpp
index ef70949d55..520cdf1378 100644
--- a/plugins/CloudFile/src/Services/dropbox_service.cpp
+++ b/plugins/CloudFile/src/Services/dropbox_service.cpp
@@ -136,10 +136,10 @@ void CDropboxService::UploadFileChunk(const char *chunk, size_t chunkSize, const
DropboxAPI::UploadFileChunkRequest request(token, sessionId, offset, chunk, chunkSize);
NLHR_PTR response(request.Send(hConnection));
- GetJsonResponse(response);
+ HandleHttpError(response);
}
-char* CDropboxService::CommitUploadSession(const char *data, size_t size, const char *sessionId, size_t offset, char *path)
+void CDropboxService::CommitUploadSession(const char *data, size_t size, const char *sessionId, size_t offset, char *path)
{
ptrA token(db_get_sa(NULL, GetModule(), "TokenSecret"));
DropboxAPI::CommitUploadSessionRequest request(token, sessionId, offset, path, data, size);
@@ -148,8 +148,6 @@ char* CDropboxService::CommitUploadSession(const char *data, size_t size, const
JSONNode root = GetJsonResponse(response);
JSONNode node = root.at("path_lower");
mir_strcpy(path, node.as_string().c_str());
-
- return path;
}
void CDropboxService::CreateFolder(const char *path)
@@ -243,8 +241,7 @@ UINT CDropboxService::Upload(FileTransferParam *ftp)
size_t offset = size;
double chunkCount = ceil(double(fileSize) / chunkSize) - 2;
- while (chunkCount--)
- {
+ while (chunkCount > 0) {
ftp->CheckCurrentFile();
size = ftp->ReadCurrentFile(data, chunkSize);
diff --git a/plugins/CloudFile/src/Services/dropbox_service.h b/plugins/CloudFile/src/Services/dropbox_service.h
index c498b52178..90dc11d259 100644
--- a/plugins/CloudFile/src/Services/dropbox_service.h
+++ b/plugins/CloudFile/src/Services/dropbox_service.h
@@ -9,10 +9,10 @@ private:
void HandleJsonError(JSONNode &node);
- char* UploadFile(const char *data, size_t size, char *path);
+ void UploadFile(const char *data, size_t size, char *path);
void CreateUploadSession(const char *chunk, size_t chunkSize, char *sessionId);
void UploadFileChunk(const char *chunk, size_t chunkSize, const char *sessionId, size_t offset);
- char* CommitUploadSession(const char *chunk, size_t chunkSize, const char *sessionId, size_t offset, char *path);
+ void CommitUploadSession(const char *chunk, size_t chunkSize, const char *sessionId, size_t offset, char *path);
void CreateFolder(const char *path);
void CreateSharedLink(const char *path, char *url);
diff --git a/plugins/CloudFile/src/Services/google_api.h b/plugins/CloudFile/src/Services/google_api.h
index c73124cdad..476a97a0e2 100644
--- a/plugins/CloudFile/src/Services/google_api.h
+++ b/plugins/CloudFile/src/Services/google_api.h
@@ -67,7 +67,7 @@ namespace GDriveAPI
body.AppendChar(0x0A);
body.Append("{");
body.AppendFormat("\"name\": \"%s\"", name);
- if (parentId)
+ if (mir_strlen(parentId))
body.AppendFormat("\"parents\": [\"%s\"]", parentId);
body.Append("}");
body.AppendChar(0x0A);
diff --git a/plugins/CloudFile/src/Services/google_service.cpp b/plugins/CloudFile/src/Services/google_service.cpp
index 92e704bbac..3fc7111822 100644
--- a/plugins/CloudFile/src/Services/google_service.cpp
+++ b/plugins/CloudFile/src/Services/google_service.cpp
@@ -264,8 +264,7 @@ UINT CGDriveService::Upload(FileTransferParam *ftp)
uint64_t offset = 0;
double chunkCount = ceil(double(fileSize) / chunkSize);
- while (chunkCount--)
- {
+ while (chunkCount > 0) {
ftp->CheckCurrentFile();
size_t size = ftp->ReadCurrentFile(chunk, chunkSize);
diff --git a/plugins/CloudFile/src/Services/microsoft_service.cpp b/plugins/CloudFile/src/Services/microsoft_service.cpp
index 77919574e0..af4dd6f703 100644
--- a/plugins/CloudFile/src/Services/microsoft_service.cpp
+++ b/plugins/CloudFile/src/Services/microsoft_service.cpp
@@ -35,7 +35,7 @@ void COneDriveService::Login()
{
ptrA token(db_get_sa(NULL, GetModule(), "TokenSecret"));
ptrA refreshToken(db_get_sa(NULL, GetModule(), "RefreshToken"));
- if (token && refreshToken && refreshToken[0]) {
+ if (token && refreshToken && refreshToken[0]) {
OneDriveAPI::RefreshTokenRequest request(refreshToken);
NLHR_PTR response(request.Send(hConnection));
@@ -246,7 +246,8 @@ UINT COneDriveService::Upload(FileTransferParam *ftp)
CreateUploadSession(uploadUri, T2Utf(fileName), folderId);
uint64_t offset = 0;
- for (size_t i = 0; i < (fileSize / chunkSize); i++) {
+ double chunkCount = ceil(double(fileSize) / chunkSize);
+ while (chunkCount > 0) {
ftp->CheckCurrentFile();
size_t size = ftp->ReadCurrentFile(chunk, chunkSize);
diff --git a/plugins/CloudFile/src/Services/yandex_service.cpp b/plugins/CloudFile/src/Services/yandex_service.cpp
index 167d9cc3f8..04d63138c0 100644
--- a/plugins/CloudFile/src/Services/yandex_service.cpp
+++ b/plugins/CloudFile/src/Services/yandex_service.cpp
@@ -250,8 +250,7 @@ UINT CYandexService::Upload(FileTransferParam *ftp)
else {
uint64_t offset = 0;
double chunkCount = ceil(double(fileSize) / chunkSize);
- while (chunkCount--)
- {
+ while (chunkCount > 0) {
ftp->CheckCurrentFile();
size_t size = ftp->ReadCurrentFile(chunk, chunkSize);