From d8d1baa7d5c286c907d18d278738331debc0aabd Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 12 Mar 2014 11:29:59 +0000 Subject: Dropbox: - fixed message with download link - fixed minor bug in file uploading git-svn-id: http://svn.miranda-ng.org/main/trunk@8570 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Dropbox/src/dropbox_transfers.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'plugins/Dropbox/src/dropbox_transfers.cpp') diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp index 6cce51ce4e..8ba7773f4b 100644 --- a/plugins/Dropbox/src/dropbox_transfers.cpp +++ b/plugins/Dropbox/src/dropbox_transfers.cpp @@ -211,9 +211,6 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg) FILE *file = _wfopen(ftp->pfts.pwszFiles[i], L"rb"); if (file) { - int offset = 0; - char *uploadId = new char[32]; - const wchar_t *fileName = NULL; if (!ftp->relativePathStart) fileName = wcsrchr(ftp->pfts.pwszFiles[i], L'\\') + 1; @@ -221,7 +218,7 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg) fileName = &ftp->pfts.pwszFiles[i][ftp->relativePathStart]; fseek(file, 0, SEEK_END); - DWORD fileSize = ftell(file); + size_t fileSize = ftell(file); fseek(file, 0, SEEK_SET); if (ftp->withVisualisation) @@ -234,13 +231,22 @@ UINT CDropbox::SendFilesAsync(void *owner, void *arg) ProtoBroadcastAck(MODULE, ftp->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ftp->hProcess, (LPARAM)&ftp->pfts); } - while (!feof(file) && !ferror(file)) + int offset = 0; + char *uploadId = new char[32]; + + int chunkSize = DROPBOX_FILE_CHUNK_SIZE / 4; + if (fileSize < 1024 * 1024) + chunkSize = DROPBOX_FILE_CHUNK_SIZE / 20; + else if (fileSize > 20 * 1024 * 1024) + chunkSize = DROPBOX_FILE_CHUNK_SIZE; + + while (!feof(file) && fileSize != offset) { - int chunkSize = DROPBOX_FILE_CHUNK_SIZE / 4; - if (fileSize < 1024 * 1024) - chunkSize = DROPBOX_FILE_CHUNK_SIZE / 20; - else if (fileSize > 20 * 1024 * 1024) - chunkSize = DROPBOX_FILE_CHUNK_SIZE; + if (ferror(file)) + { + error = true; + break; + } char *data = new char[chunkSize + 1]; int count = (int)fread(data, sizeof(char), chunkSize, file); -- cgit v1.2.3