|
@@ -30,6 +30,7 @@ import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
import android.util.Pair;
|
|
|
|
|
|
+import com.nextcloud.client.account.User;
|
|
|
import com.nextcloud.client.device.BatteryStatus;
|
|
|
import com.nextcloud.client.device.PowerManagementService;
|
|
|
import com.nextcloud.client.network.Connectivity;
|
|
@@ -139,7 +140,7 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
|
|
|
private RequestEntity mEntity;
|
|
|
|
|
|
- private final Account mAccount;
|
|
|
+ private final User user;
|
|
|
private final OCUpload mUpload;
|
|
|
private final UploadsStorageManager uploadsStorageManager;
|
|
|
private final ConnectivityService connectivityService;
|
|
@@ -176,7 +177,7 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
public UploadFileOperation(UploadsStorageManager uploadsStorageManager,
|
|
|
ConnectivityService connectivityService,
|
|
|
PowerManagementService powerManagementService,
|
|
|
- Account account,
|
|
|
+ User user,
|
|
|
OCFile file,
|
|
|
OCUpload upload,
|
|
|
FileUploader.NameCollisionPolicy nameCollisionPolicy,
|
|
@@ -185,9 +186,6 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
boolean onWifiOnly,
|
|
|
boolean whileChargingOnly
|
|
|
) {
|
|
|
- if (account == null) {
|
|
|
- throw new IllegalArgumentException("Illegal NULL account in UploadFileOperation " + "creation");
|
|
|
- }
|
|
|
if (upload == null) {
|
|
|
throw new IllegalArgumentException("Illegal NULL file in UploadFileOperation creation");
|
|
|
}
|
|
@@ -200,7 +198,7 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
this.uploadsStorageManager = uploadsStorageManager;
|
|
|
this.connectivityService = connectivityService;
|
|
|
this.powerManagementService = powerManagementService;
|
|
|
- mAccount = account;
|
|
|
+ this.user = user;
|
|
|
mUpload = upload;
|
|
|
if (file == null) {
|
|
|
mFile = obtainNewOCFileToUpload(
|
|
@@ -237,7 +235,7 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
public boolean isIgnoringPowerSaveMode() { return mIgnoringPowerSaveMode; }
|
|
|
|
|
|
public Account getAccount() {
|
|
|
- return mAccount;
|
|
|
+ return user.toPlatformAccount();
|
|
|
}
|
|
|
|
|
|
public String getFileName() {
|
|
@@ -477,7 +475,7 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
return collisionResult;
|
|
|
}
|
|
|
|
|
|
- String expectedPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile);
|
|
|
+ String expectedPath = FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), mFile);
|
|
|
expectedFile = new File(expectedPath);
|
|
|
|
|
|
result = copyFile(originalFile, expectedPath);
|
|
@@ -520,7 +518,7 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
} catch (FileNotFoundException e) {
|
|
|
// this basically means that the file is on SD card
|
|
|
// try to copy file to temporary dir if it doesn't exist
|
|
|
- String temporalPath = FileStorageUtils.getInternalTemporalPath(mAccount.name, mContext) +
|
|
|
+ String temporalPath = FileStorageUtils.getInternalTemporalPath(user.getAccountName(), mContext) +
|
|
|
mFile.getRemotePath();
|
|
|
mFile.setStoragePath(temporalPath);
|
|
|
temporalFile = new File(temporalPath);
|
|
@@ -729,7 +727,7 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
return collisionResult;
|
|
|
}
|
|
|
|
|
|
- String expectedPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile);
|
|
|
+ String expectedPath = FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), mFile);
|
|
|
expectedFile = new File(expectedPath);
|
|
|
|
|
|
result = copyFile(originalFile, expectedPath);
|
|
@@ -748,7 +746,7 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
} catch (FileNotFoundException e) {
|
|
|
// this basically means that the file is on SD card
|
|
|
// try to copy file to temporary dir if it doesn't exist
|
|
|
- String temporalPath = FileStorageUtils.getInternalTemporalPath(mAccount.name, mContext) +
|
|
|
+ String temporalPath = FileStorageUtils.getInternalTemporalPath(user.getAccountName(), mContext) +
|
|
|
mFile.getRemotePath();
|
|
|
mFile.setStoragePath(temporalPath);
|
|
|
temporalFile = new File(temporalPath);
|
|
@@ -876,7 +874,7 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
private RemoteOperationResult copyFile(File originalFile, String expectedPath) throws OperationCancelledException,
|
|
|
IOException {
|
|
|
if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_COPY && !mOriginalStoragePath.equals(expectedPath)) {
|
|
|
- String temporalPath = FileStorageUtils.getInternalTemporalPath(mAccount.name, mContext) +
|
|
|
+ String temporalPath = FileStorageUtils.getInternalTemporalPath(user.getAccountName(), mContext) +
|
|
|
mFile.getRemotePath();
|
|
|
mFile.setStoragePath(temporalPath);
|
|
|
File temporalFile = new File(temporalPath);
|
|
@@ -958,7 +956,7 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
break;
|
|
|
|
|
|
case FileUploader.LOCAL_BEHAVIOUR_MOVE:
|
|
|
- String expectedPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile);
|
|
|
+ String expectedPath = FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), mFile);
|
|
|
File newFile = new File(expectedPath);
|
|
|
|
|
|
try {
|
|
@@ -991,7 +989,7 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
RemoteOperation operation = new ExistenceCheckRemoteOperation(pathToGrant, false);
|
|
|
RemoteOperationResult result = operation.execute(client);
|
|
|
if (!result.isSuccess() && result.getCode() == ResultCode.FILE_NOT_FOUND && mRemoteFolderToBeCreated) {
|
|
|
- SyncOperation syncOp = new CreateFolderOperation(pathToGrant, getAccount(), getContext());
|
|
|
+ SyncOperation syncOp = new CreateFolderOperation(pathToGrant, user, getContext());
|
|
|
result = syncOp.execute(client, getStorageManager());
|
|
|
}
|
|
|
if (result.isSuccess()) {
|
|
@@ -1310,7 +1308,7 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
|
|
|
// generate new Thumbnail
|
|
|
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
|
|
- new ThumbnailsCacheManager.ThumbnailGenerationTask(getStorageManager(), mAccount);
|
|
|
+ new ThumbnailsCacheManager.ThumbnailGenerationTask(getStorageManager(), user.toPlatformAccount());
|
|
|
task.execute(new ThumbnailsCacheManager.ThumbnailGenerationTaskObject(file, file.getRemoteId()));
|
|
|
}
|
|
|
|