|
@@ -20,12 +20,12 @@
|
|
|
|
|
|
package com.owncloud.android.operations;
|
|
|
|
|
|
-import android.accounts.Account;
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
|
|
|
+import com.nextcloud.client.account.User;
|
|
|
import com.owncloud.android.datamodel.FileDataStorageManager;
|
|
|
import com.owncloud.android.datamodel.OCFile;
|
|
|
import com.owncloud.android.files.services.FileDownloader;
|
|
@@ -71,7 +71,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
private String mRemotePath;
|
|
|
|
|
|
/** Account where the file to synchronize belongs */
|
|
|
- private Account mAccount;
|
|
|
+ private User user;
|
|
|
|
|
|
/** Android context; necessary to send requests to the download service */
|
|
|
private Context mContext;
|
|
@@ -101,14 +101,13 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
*
|
|
|
* @param context Application context.
|
|
|
* @param remotePath Path to synchronize.
|
|
|
- * @param account ownCloud account where the folder is located.
|
|
|
+ * @param user Nextcloud account where the folder is located.
|
|
|
* @param currentSyncTime Time stamp for the synchronization process in progress.
|
|
|
*/
|
|
|
- public SynchronizeFolderOperation(Context context, String remotePath, Account account,
|
|
|
- long currentSyncTime){
|
|
|
+ public SynchronizeFolderOperation(Context context, String remotePath, User user, long currentSyncTime){
|
|
|
mRemotePath = remotePath;
|
|
|
mCurrentSyncTime = currentSyncTime;
|
|
|
- mAccount = account;
|
|
|
+ this.user = user;
|
|
|
mContext = context;
|
|
|
mRemoteFolderChanged = false;
|
|
|
mFilesForDirectDownload = new Vector<>();
|
|
@@ -159,7 +158,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
}
|
|
|
|
|
|
private RemoteOperationResult checkForChanges(OwnCloudClient client) throws OperationCancelledException {
|
|
|
- Log_OC.d(TAG, "Checking changes in " + mAccount.name + mRemotePath);
|
|
|
+ Log_OC.d(TAG, "Checking changes in " + user.getAccountName() + mRemotePath);
|
|
|
|
|
|
mRemoteFolderChanged = true;
|
|
|
|
|
@@ -178,7 +177,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
|
|
|
result = new RemoteOperationResult(ResultCode.OK);
|
|
|
|
|
|
- Log_OC.i(TAG, "Checked " + mAccount.name + mRemotePath + " : " +
|
|
|
+ Log_OC.i(TAG, "Checked " + user.getAccountName() + mRemotePath + " : " +
|
|
|
(mRemoteFolderChanged ? "changed" : "not changed"));
|
|
|
|
|
|
} else {
|
|
@@ -187,10 +186,10 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
removeLocalFolder();
|
|
|
}
|
|
|
if (result.isException()) {
|
|
|
- Log_OC.e(TAG, "Checked " + mAccount.name + mRemotePath + " : " +
|
|
|
+ Log_OC.e(TAG, "Checked " + user.getAccountName() + mRemotePath + " : " +
|
|
|
result.getLogMessage(), result.getException());
|
|
|
} else {
|
|
|
- Log_OC.e(TAG, "Checked " + mAccount.name + mRemotePath + " : " +
|
|
|
+ Log_OC.e(TAG, "Checked " + user.getAccountName() + mRemotePath + " : " +
|
|
|
result.getLogMessage());
|
|
|
}
|
|
|
|
|
@@ -207,7 +206,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
|
|
|
ReadFolderRemoteOperation operation = new ReadFolderRemoteOperation(mRemotePath);
|
|
|
RemoteOperationResult result = operation.execute(client);
|
|
|
- Log_OC.d(TAG, "Synchronizing " + mAccount.name + mRemotePath);
|
|
|
+ Log_OC.d(TAG, "Synchronizing " + user.getAccountName() + mRemotePath);
|
|
|
|
|
|
if (result.isSuccess()) {
|
|
|
synchronizeData(result.getData());
|
|
@@ -228,7 +227,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
private void removeLocalFolder() {
|
|
|
FileDataStorageManager storageManager = getStorageManager();
|
|
|
if (storageManager.fileExists(mLocalFolder.getFileId())) {
|
|
|
- String currentSavePath = FileStorageUtils.getSavePath(mAccount.name);
|
|
|
+ String currentSavePath = FileStorageUtils.getSavePath(user.getAccountName());
|
|
|
storageManager.removeFolder(
|
|
|
mLocalFolder,
|
|
|
true,
|
|
@@ -351,7 +350,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
SynchronizeFileOperation operation = new SynchronizeFileOperation(
|
|
|
localFile,
|
|
|
remoteFile,
|
|
|
- mAccount,
|
|
|
+ user,
|
|
|
true,
|
|
|
mContext
|
|
|
);
|
|
@@ -383,7 +382,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
SynchronizeFileOperation operation = new SynchronizeFileOperation(
|
|
|
child,
|
|
|
child.getEtagInConflict() != null ? child : null,
|
|
|
- mAccount,
|
|
|
+ user,
|
|
|
true,
|
|
|
mContext
|
|
|
);
|
|
@@ -409,7 +408,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
throw new OperationCancelledException();
|
|
|
}
|
|
|
Intent i = new Intent(mContext, FileDownloader.class);
|
|
|
- i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
|
|
|
+ i.putExtra(FileDownloader.EXTRA_USER, user);
|
|
|
i.putExtra(FileDownloader.EXTRA_FILE, file);
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
|
|
mContext.startForegroundService(i);
|
|
@@ -465,7 +464,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
*/
|
|
|
private void searchForLocalFileInDefaultPath(OCFile file) {
|
|
|
if (file.getStoragePath() == null && !file.isFolder()) {
|
|
|
- File f = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, file));
|
|
|
+ File f = new File(FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), file));
|
|
|
if (f.exists()) {
|
|
|
file.setStoragePath(f.getAbsolutePath());
|
|
|
file.setLastSyncDateForData(f.lastModified());
|
|
@@ -486,13 +485,13 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
|
|
if (!TextUtils.isEmpty(path)) {
|
|
|
return path;
|
|
|
}
|
|
|
- return FileStorageUtils.getDefaultSavePathFor(mAccount.name, mLocalFolder);
|
|
|
+ return FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), mLocalFolder);
|
|
|
}
|
|
|
|
|
|
private void startSyncFolderOperation(String path){
|
|
|
Intent intent = new Intent(mContext, OperationsService.class);
|
|
|
intent.setAction(OperationsService.ACTION_SYNC_FOLDER);
|
|
|
- intent.putExtra(OperationsService.EXTRA_ACCOUNT, mAccount);
|
|
|
+ intent.putExtra(OperationsService.EXTRA_ACCOUNT, user);
|
|
|
intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, path);
|
|
|
mContext.startService(intent);
|
|
|
}
|