mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
Fixed NullPointerExceptionS in upload cancelations
This commit is contained in:
parent
9b5506f81e
commit
c0c52fa16a
4 changed files with 45 additions and 53 deletions
|
@ -438,13 +438,8 @@ public class FileDownloader extends Service
|
|||
saveDownloadedFile();
|
||||
}
|
||||
|
||||
} catch (AccountsException e) {
|
||||
Log_OC.e(TAG, "Error while trying to get authorization for "
|
||||
+ mCurrentAccount.name, e);
|
||||
downloadResult = new RemoteOperationResult(e);
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "Error while trying to get authorization for "
|
||||
+ mCurrentAccount.name, e);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Error downloading", e);
|
||||
downloadResult = new RemoteOperationResult(e);
|
||||
|
||||
} finally {
|
||||
|
|
|
@ -583,14 +583,8 @@ public class FileUploader extends Service
|
|||
uploadResult = grantResult;
|
||||
}
|
||||
|
||||
} catch (AccountsException e) {
|
||||
Log_OC.e(TAG, "Error while trying to get autorization for " +
|
||||
mCurrentAccount.name, e);
|
||||
uploadResult = new RemoteOperationResult(e);
|
||||
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "Error while trying to get autorization for " +
|
||||
mCurrentAccount.name, e);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Error uploading", e);
|
||||
uploadResult = new RemoteOperationResult(e);
|
||||
|
||||
} finally {
|
||||
|
|
|
@ -221,6 +221,12 @@ public class SynchronizeFileOperation extends SyncOperation {
|
|||
mLocalFile.getLocalModificationTimestamp() > mLocalFile.getLastSyncDateForData()
|
||||
);
|
||||
|
||||
Log_OC.d(TAG, "TOKENs checked to SYNC " + mRemotePath );
|
||||
Log_OC.d(TAG, " server#modificationTimestamp " + mServerFile.getModificationTimestamp());
|
||||
Log_OC.d(TAG, " local#modificationTimestampAtLastSyncForData " + mServerFile.getModificationTimestampAtLastSyncForData());
|
||||
Log_OC.d(TAG, " local#modificationTimestamp " + mLocalFile.getLocalModificationTimestamp());
|
||||
Log_OC.d(TAG, " local#lastSyncDateForData " + mLocalFile.getLastSyncDateForData());
|
||||
|
||||
/// decide action to perform depending upon changes
|
||||
//if (!mLocalFile.getEtag().isEmpty() && localChanged && serverChanged) {
|
||||
if (localChanged && serverChanged) {
|
||||
|
|
|
@ -321,7 +321,10 @@ public class UploadFileOperation extends RemoteOperation {
|
|||
while (listener.hasNext()) {
|
||||
mUploadOperation.addDatatransferProgressListener(listener.next());
|
||||
}
|
||||
if (!mCancellationRequested.get()) {
|
||||
if (mCancellationRequested.get()) {
|
||||
throw new OperationCancelledException();
|
||||
}
|
||||
|
||||
result = mUploadOperation.execute(client);
|
||||
|
||||
/// move local temporal file or original file to its corresponding
|
||||
|
@ -358,15 +361,9 @@ public class UploadFileOperation extends RemoteOperation {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO something cleaner with cancellations
|
||||
if (mCancellationRequested.get()) {
|
||||
result = new RemoteOperationResult(new OperationCancelledException());
|
||||
} else {
|
||||
result = new RemoteOperationResult(e);
|
||||
}
|
||||
|
||||
} finally {
|
||||
if (temporalFile != null && !originalFile.equals(temporalFile)) {
|
||||
|
|
Loading…
Reference in a new issue