projects
/
pub
/
Android
/
ownCloud.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Notify the download cancelation for updating the screen and remove the yellow arrow...
[pub/Android/ownCloud.git]
/
src
/
com
/
owncloud
/
android
/
operations
/
SynchronizeFolderOperation.java
diff --git
a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java
b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java
index
6b62547
..
f12d5dd
100644
(file)
--- a/
src/com/owncloud/android/operations/SynchronizeFolderOperation.java
+++ b/
src/com/owncloud/android/operations/SynchronizeFolderOperation.java
@@
-172,12
+172,11
@@
public class SynchronizeFolderOperation extends SyncOperation {
} catch (OperationCancelledException e) {
result = new RemoteOperationResult(e);
} catch (OperationCancelledException e) {
result = new RemoteOperationResult(e);
-
- // cancel 'child' synchronizations
- for (SyncOperation synchOp: mFoldersToWalkDown) {
- ((SynchronizeFolderOperation) synchOp).cancel();
- }
-
+
+ // Needed in case that cancellation occurs before starting any download.
+ // If not, yellow arrow continues being shown.
+ sendBroadcastForNotifyingUIUpdate(result.isSuccess());
+
/// cancellation of download needs to be done separately in any case; a SynchronizeFolderOperation
// may finish much sooner than the real download of the files in the folder
Intent intent = new Intent(mContext, FileDownloader.class);
/// cancellation of download needs to be done separately in any case; a SynchronizeFolderOperation
// may finish much sooner than the real download of the files in the folder
Intent intent = new Intent(mContext, FileDownloader.class);
@@
-288,7
+287,8
@@
public class SynchronizeFolderOperation extends SyncOperation {
* retrieved.
* @return 'True' when any change was made in the local data, 'false' otherwise
*/
* retrieved.
* @return 'True' when any change was made in the local data, 'false' otherwise
*/
- private void synchronizeData(ArrayList<Object> folderAndFiles, OwnCloudClient client) {
+ private void synchronizeData(ArrayList<Object> folderAndFiles, OwnCloudClient client)
+ throws OperationCancelledException {
FileDataStorageManager storageManager = getStorageManager();
// parse data from remote folder
FileDataStorageManager storageManager = getStorageManager();
// parse data from remote folder
@@
-303,7
+303,13
@@
public class SynchronizeFolderOperation extends SyncOperation {
mFilesForDirectDownload.clear();
mFilesToSyncContentsWithoutUpload.clear();
mFavouriteFilesToSyncContents.clear();
mFilesForDirectDownload.clear();
mFilesToSyncContentsWithoutUpload.clear();
mFavouriteFilesToSyncContents.clear();
- mFoldersToWalkDown.clear();
+
+ synchronized(mFoldersToWalkDown) {
+ if (mCancellationRequested.get()) {
+ throw new OperationCancelledException();
+ }
+ mFoldersToWalkDown.clear();
+ }
// get current data about local contents of the folder to synchronize
List<OCFile> localFiles = storageManager.getFolderContent(mLocalFolder);
// get current data about local contents of the folder to synchronize
List<OCFile> localFiles = storageManager.getFolderContent(mLocalFolder);
@@
-365,8
+371,14
@@
public class SynchronizeFolderOperation extends SyncOperation {
mAccount,
mCurrentSyncTime
);
mAccount,
mCurrentSyncTime
);
- mFoldersToWalkDown.add(synchFolderOp);
-
+
+ synchronized(mFoldersToWalkDown) {
+ if (mCancellationRequested.get()) {
+ throw new OperationCancelledException();
+ }
+ mFoldersToWalkDown.add(synchFolderOp);
+ }
+
} else if (remoteFile.keepInSync()) {
/// prepare content synchronization for kept-in-sync files
SynchronizeFileOperation operation = new SynchronizeFileOperation(
} else if (remoteFile.keepInSync()) {
/// prepare content synchronization for kept-in-sync files
SynchronizeFileOperation operation = new SynchronizeFileOperation(
@@
-400,7
+412,7
@@
public class SynchronizeFolderOperation extends SyncOperation {
}
}
- private void prepareOpsFromLocalKnowledge() {
+ private void prepareOpsFromLocalKnowledge()
throws OperationCancelledException
{
List<OCFile> children = getStorageManager().getFolderContent(mLocalFolder);
for (OCFile child : children) {
/// classify file to sync/download contents later
List<OCFile> children = getStorageManager().getFolderContent(mLocalFolder);
for (OCFile child : children) {
/// classify file to sync/download contents later
@@
-412,8
+424,14
@@
public class SynchronizeFolderOperation extends SyncOperation {
mAccount,
mCurrentSyncTime
);
mAccount,
mCurrentSyncTime
);
- mFoldersToWalkDown.add(synchFolderOp);
-
+
+ synchronized(mFoldersToWalkDown) {
+ if (mCancellationRequested.get()) {
+ throw new OperationCancelledException();
+ }
+ mFoldersToWalkDown.add(synchFolderOp);
+ }
+
} else {
/// prepare limited synchronization for regular files
if (!child.isDown()) {
} else {
/// prepare limited synchronization for regular files
if (!child.isDown()) {
@@
-554,6
+572,13
@@
public class SynchronizeFolderOperation extends SyncOperation {
*/
public void cancel() {
mCancellationRequested.set(true);
*/
public void cancel() {
mCancellationRequested.set(true);
+
+ synchronized(mFoldersToWalkDown) {
+ // cancel 'child' synchronizations
+ for (SyncOperation synchOp : mFoldersToWalkDown) {
+ ((SynchronizeFolderOperation) synchOp).cancel();
+ }
+ }
}
public String getFolderPath() {
}
public String getFolderPath() {