Merge branch 'download_folder' into download_folder__fixing_recursive_cancellation
authorjabarros <jabarros@solidgear.es>
Thu, 8 Jan 2015 13:26:38 +0000 (14:26 +0100)
committerjabarros <jabarros@solidgear.es>
Thu, 8 Jan 2015 13:26:38 +0000 (14:26 +0100)
1  2 
src/com/owncloud/android/operations/SynchronizeFolderOperation.java

@@@ -165,11 -165,6 +165,11 @@@ public class SynchronizeFolderOperatio
                      sendBroadcastForNotifyingUIUpdate(result.isSuccess());
                  }
              }
 +            
 +            if (mCancellationRequested.get()) {
 +                throw new OperationCancelledException();
 +            }
 +            
          } catch (OperationCancelledException e) {
              result = new RemoteOperationResult(e);
              
              for (SyncOperation  synchOp: mFoldersToWalkDown) {
                  ((SynchronizeFolderOperation) synchOp).cancel();
              }
 +            
 +            /// 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);
 +            intent.setAction(FileDownloader.ACTION_CANCEL_FILE_DOWNLOAD);
 +            intent.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
 +            intent.putExtra(FileDownloader.EXTRA_FILE, mLocalFolder);
 +            mContext.startService(intent);            
          }
  
          return result;
      public void cancel() {
          mCancellationRequested.set(true);
      }
+     public String getFolderPath() {
+         String path = mLocalFolder.getStoragePath();
+         if (path != null && path.length() > 0) {
+             return path;
+         }
+         return FileStorageUtils.getDefaultSavePathFor(mAccount.name, mLocalFolder);
+     }
  }