- } else {
- uploadResult = grantResult;
- }
-
- } catch (AccountsException e) {
- Log_OC.e(TAG, "Error while trying to get autorization for " + mLastAccount.name, e);
- uploadResult = new RemoteOperationResult(e);
-
- } catch (IOException e) {
- Log_OC.e(TAG, "Error while trying to get autorization for " + mLastAccount.name, e);
- uploadResult = new RemoteOperationResult(e);
-
- } finally {
- synchronized (mPendingUploads) {
- mPendingUploads.remove(uploadKey);
- Log_OC.i(TAG, "Remove CurrentUploadItem from pending upload Item Map.");
- }
- if (uploadResult.isException()) {
- // enforce the creation of a new client object for next uploads; this grant that a new socket will
- // be created in the future if the current exception is due to an abrupt lose of network connection
- mUploadClient = null;
+
+ } catch (Exception e) {
+ Log_OC.e(TAG, "Error uploading", e);
+ uploadResult = new RemoteOperationResult(e);
+
+ } finally {
+ Pair<UploadFileOperation, String> removeResult;
+ if (mCurrentUpload.wasRenamed()) {
+ removeResult = mPendingUploads.removePayload(
+ mCurrentAccount,
+ mCurrentUpload.getOldFile().getRemotePath()
+ );
+ } else {
+ removeResult = mPendingUploads.removePayload(
+ mCurrentAccount,
+ mCurrentUpload.getRemotePath()
+ );
+ }
+
+ /// notify result
+ notifyUploadResult(mCurrentUpload, uploadResult);
+
+ sendBroadcastUploadFinished(mCurrentUpload, uploadResult, removeResult.second);