From 8b3ed707912a3b58346e2d617c53081fd0ff52bf Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Wed, 7 Oct 2015 22:35:55 +0200 Subject: [PATCH] wip --- .../android/files/InstantUploadBroadcastReceiver.java | 9 ++++++--- .../owncloud/android/files/services/FileUploader.java | 10 ++++++++++ .../android/operations/UploadFileOperation.java | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java index 400a6de32b..eb628f0db9 100644 --- a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java +++ b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java @@ -195,10 +195,13 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver { && (!instantPictureUploadViaWiFiOnly(context) || (instantPictureUploadViaWiFiOnly(context) == isConnectedViaWiFi(context) == true))) { DbHandler db = new DbHandler(context); Cursor c = db.getAwaitingFiles(); - if (c.moveToFirst() && isOnline(context) - && (!instantPictureUploadViaWiFiOnly(context) || - (instantPictureUploadViaWiFiOnly(context) == isConnectedViaWiFi(context) == true))) { + if (c.moveToFirst()) { do { + if (instantPictureUploadViaWiFiOnly(context) && + !isConnectedViaWiFi(context)){ + break; + } + String account_name = c.getString(c.getColumnIndex("account")); String file_path = c.getString(c.getColumnIndex("path")); File f = new File(file_path); diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index 62a05ea7ac..dc23bd142e 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -213,6 +213,16 @@ public class FileUploader extends Service if (intent.hasExtra(KEY_CANCEL_ALL) && intent.hasExtra(KEY_ACCOUNT)){ Account account = intent.getParcelableExtra(KEY_ACCOUNT); + + Log_OC.d(TAG, "Account= " + account.name); + + if (mCurrentUpload != null) { + Log_OC.d(TAG, "Current Upload Account= " + mCurrentUpload.getAccount().name); + if (mCurrentUpload.getAccount().name.equals(account.name)) { + mCurrentUpload.cancel(); + } + } + // Cancel pending uploads cancelUploadForAccount(account.name); } diff --git a/src/com/owncloud/android/operations/UploadFileOperation.java b/src/com/owncloud/android/operations/UploadFileOperation.java index 12cf1ac74c..8c449ed44f 100644 --- a/src/com/owncloud/android/operations/UploadFileOperation.java +++ b/src/com/owncloud/android/operations/UploadFileOperation.java @@ -372,6 +372,9 @@ public class UploadFileOperation extends RemoteOperation { if (temporalFile != null && !originalFile.equals(temporalFile)) { temporalFile.delete(); } + if (result == null){ + return new RemoteOperationResult(false, 404, null); + } if (result.isSuccess()) { Log_OC.i(TAG, "Upload of " + mOriginalStoragePath + " to " + mRemotePath + ": " + result.getLogMessage());