X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/d860ae7cd462d08e3de523e2a6f29850bb8d2e96..d83491f62df97f912c650f0de499a87d14a494d0:/src/com/owncloud/android/services/SyncFolderHandler.java diff --git a/src/com/owncloud/android/services/SyncFolderHandler.java b/src/com/owncloud/android/services/SyncFolderHandler.java index b0116b32..57271eb5 100644 --- a/src/com/owncloud/android/services/SyncFolderHandler.java +++ b/src/com/owncloud/android/services/SyncFolderHandler.java @@ -1,4 +1,6 @@ -/* ownCloud Android client application +/** + * ownCloud Android client application + * * Copyright (C) 2015 ownCloud Inc. * * This program is free software: you can redistribute it and/or modify @@ -87,6 +89,7 @@ class SyncFolderHandler extends Handler { public void handleMessage(Message msg) { Pair itemSyncKey = (Pair) msg.obj; doOperation(itemSyncKey.first, itemSyncKey.second); + Log_OC.d(TAG, "Stopping after command with id " + msg.arg1); mService.stopSelf(msg.arg1); } @@ -102,29 +105,30 @@ class SyncFolderHandler extends Handler { RemoteOperationResult result = null; try { - if (mOwnCloudClient == null || !account.equals(mCurrentAccount)) { - /// get client object to send the request to the ownCloud server, if cannot + + if (mCurrentAccount == null || !mCurrentAccount.equals(account)) { mCurrentAccount = account; mStorageManager = new FileDataStorageManager( account, mService.getContentResolver() ); - OwnCloudAccount ocAccount = new OwnCloudAccount(account, mService); - mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton(). - getClientFor(ocAccount, mService); + } // else, reuse storage manager from previous operation - } // else, reuse client from previous operation + // always get client from client manager, to get fresh credentials in case of update + OwnCloudAccount ocAccount = new OwnCloudAccount(account, mService); + mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton(). + getClientFor(ocAccount, mService); result = mCurrentSyncOperation.execute(mOwnCloudClient, mStorageManager); } catch (AccountsException e) { - Log_OC.e(TAG, "Error while trying to get autorization", e); + Log_OC.e(TAG, "Error while trying to get authorization", e); } catch (IOException e) { - Log_OC.e(TAG, "Error while trying to get autorization", e); + Log_OC.e(TAG, "Error while trying to get authorization", e); } finally { mPendingOperations.removePayload(account, remotePath); - mService.dispatchResultToOperationListeners(null, mCurrentSyncOperation, result); + mService.dispatchResultToOperationListeners(mCurrentSyncOperation, result); sendBroadcastFinishedSyncFolder(account, remotePath, result.isSuccess()); } @@ -154,9 +158,9 @@ class SyncFolderHandler extends Handler { if (synchronization != null) { synchronization.cancel(); } else { - // TODO synchronize + // TODO synchronize? if (mCurrentSyncOperation != null && mCurrentAccount != null && - mCurrentSyncOperation.getFolderPath().startsWith(file.getRemotePath()) && + mCurrentSyncOperation.getRemotePath().startsWith(file.getRemotePath()) && account.name.equals(mCurrentAccount.name)) { mCurrentSyncOperation.cancel(); }