Merge pull request #6559 from nextcloud/downloadTest
Download / upload tests
This commit is contained in:
commit
cc750123a7
|
@ -28,20 +28,24 @@ import com.owncloud.android.AbstractOnServerIT;
|
|||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.e2ee.ToggleEncryptionRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.lib.resources.users.GetPrivateKeyOperation;
|
||||
import com.owncloud.android.lib.resources.users.GetPublicKeyOperation;
|
||||
import com.owncloud.android.lib.resources.users.SendCSROperation;
|
||||
import com.owncloud.android.lib.resources.users.StorePrivateKeyOperation;
|
||||
import com.owncloud.android.operations.DownloadFileOperation;
|
||||
import com.owncloud.android.operations.GetCapabilitiesOperation;
|
||||
import com.owncloud.android.operations.RemoveFileOperation;
|
||||
import com.owncloud.android.utils.CsrHelper;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import net.bytebuddy.utility.RandomString;
|
||||
|
||||
|
@ -59,6 +63,7 @@ import java.util.Random;
|
|||
|
||||
import static com.owncloud.android.lib.resources.status.OwnCloudVersion.nextcloud_19;
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
@ -68,7 +73,9 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
|||
CREATE_FOLDER,
|
||||
GO_INTO_FOLDER,
|
||||
GO_UP,
|
||||
UPLOAD_FILE
|
||||
UPLOAD_FILE,
|
||||
DOWNLOAD_FILE,
|
||||
DELETE_FILE,
|
||||
}
|
||||
|
||||
private static ArbitraryDataProvider arbitraryDataProvider;
|
||||
|
@ -83,7 +90,7 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
|||
}
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
public void before() throws IOException {
|
||||
OCCapability capability = getStorageManager().getCapability(account.name);
|
||||
|
||||
if (capability.getVersion().equals(new OwnCloudVersion("0.0.0"))) {
|
||||
|
@ -97,6 +104,8 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
|||
.isNewerOrEqual(nextcloud_19)
|
||||
);
|
||||
|
||||
// make sure that every file is available, even after tests that remove source file
|
||||
createDummyFiles();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -123,6 +132,14 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
|||
uploadFile(i);
|
||||
break;
|
||||
|
||||
case DOWNLOAD_FILE:
|
||||
downloadFile(i);
|
||||
break;
|
||||
|
||||
case DELETE_FILE:
|
||||
deleteFile(i);
|
||||
break;
|
||||
|
||||
default:
|
||||
Log_OC.d(this, "[" + i + "/" + actionCount + "]" + " Unknown action: " + nextAction);
|
||||
break;
|
||||
|
@ -208,6 +225,14 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
|||
deleteFile(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void downloadFile() throws Exception {
|
||||
init();
|
||||
|
||||
uploadFile(1);
|
||||
downloadFile(1);
|
||||
}
|
||||
|
||||
private void init() throws Exception {
|
||||
// create folder
|
||||
createFolder(rootEncFolder);
|
||||
|
@ -288,6 +313,131 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
|||
remotePath,
|
||||
account.name);
|
||||
uploadOCUpload(ocUpload);
|
||||
shortSleep();
|
||||
|
||||
OCFile parentFolder = getStorageManager()
|
||||
.getFileByEncryptedRemotePath(new File(ocUpload.getRemotePath()).getParent() + "/");
|
||||
String uploadedFileName = new File(ocUpload.getRemotePath()).getName();
|
||||
|
||||
String decryptedPath = parentFolder.getDecryptedRemotePath() + uploadedFileName;
|
||||
|
||||
OCFile uploadedFile = getStorageManager().getFileByDecryptedRemotePath(decryptedPath);
|
||||
verifyStoragePath(uploadedFile);
|
||||
|
||||
// verify storage path
|
||||
refreshFolder(currentFolder.getRemotePath());
|
||||
uploadedFile = getStorageManager().getFileByDecryptedRemotePath(decryptedPath);
|
||||
verifyStoragePath(uploadedFile);
|
||||
|
||||
// verify that encrypted file is on server
|
||||
assertTrue(new ReadFileRemoteOperation(currentFolder.getRemotePath() + uploadedFile.getEncryptedFileName())
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
|
||||
// verify that unencrypted file is not on server
|
||||
assertFalse(new ReadFileRemoteOperation(currentFolder.getDecryptedRemotePath() + fileName)
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
private void downloadFile(int i) {
|
||||
ArrayList<OCFile> files = new ArrayList<>();
|
||||
for (OCFile file : getStorageManager().getFolderContent(currentFolder, false)) {
|
||||
if (!file.isFolder()) {
|
||||
files.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (files.isEmpty()) {
|
||||
Log_OC.d(this, "[" + i + "/" + actionCount + "] No files in: " + currentFolder.getDecryptedRemotePath());
|
||||
return;
|
||||
}
|
||||
|
||||
OCFile fileToDownload = files.get(new Random().nextInt(files.size()));
|
||||
assertNotNull(fileToDownload.getRemoteId());
|
||||
|
||||
Log_OC.d(this,
|
||||
"[" + i + "/" + actionCount + "] " + "Download file: " +
|
||||
currentFolder.getDecryptedRemotePath() + fileToDownload.getDecryptedFileName());
|
||||
|
||||
assertTrue(new DownloadFileOperation(account, fileToDownload, targetContext)
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
|
||||
assertTrue(new File(fileToDownload.getStoragePath()).exists());
|
||||
verifyStoragePath(fileToDownload);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithCopy() throws Exception {
|
||||
init();
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
currentFolder.getRemotePath() + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_COPY);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
|
||||
"nonEmpty.txt");
|
||||
|
||||
assertTrue(originalFile.exists());
|
||||
assertTrue(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithMove() throws Exception {
|
||||
init();
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
currentFolder.getRemotePath() + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_MOVE);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
|
||||
"nonEmpty.txt");
|
||||
|
||||
assertFalse(originalFile.exists());
|
||||
assertTrue(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithForget() throws Exception {
|
||||
init();
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
currentFolder.getRemotePath() + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_FORGET);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
|
||||
"nonEmpty.txt");
|
||||
|
||||
assertTrue(originalFile.exists());
|
||||
assertFalse(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithDelete() throws Exception {
|
||||
init();
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
currentFolder.getRemotePath() + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_DELETE);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
|
||||
"nonEmpty.txt");
|
||||
|
||||
assertFalse(originalFile.exists());
|
||||
assertFalse(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
|
||||
private void deleteFile(int i) {
|
||||
|
@ -298,6 +448,11 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
|||
}
|
||||
}
|
||||
|
||||
if (files.isEmpty()) {
|
||||
Log_OC.d(this, "[" + i + "/" + actionCount + "] No files in: " + currentFolder.getDecryptedRemotePath());
|
||||
return;
|
||||
}
|
||||
|
||||
OCFile fileToDelete = files.get(new Random().nextInt(files.size()));
|
||||
assertNotNull(fileToDelete.getRemoteId());
|
||||
|
||||
|
@ -467,4 +622,11 @@ public class EndToEndRandomIT extends AbstractOnServerIT {
|
|||
|
||||
Log_OC.d(this, "Finished removing content of folder: " + folder.getDecryptedRemotePath());
|
||||
}
|
||||
|
||||
private void verifyStoragePath(OCFile file) {
|
||||
assertEquals(FileStorageUtils.getSavePath(account.name) +
|
||||
currentFolder.getDecryptedRemotePath() +
|
||||
file.getDecryptedFileName(),
|
||||
file.getStoragePath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,8 +185,48 @@ public abstract class AbstractIT {
|
|||
return AccountManager.get(targetContext).getAccounts();
|
||||
}
|
||||
|
||||
protected static void createDummyFiles() throws IOException {
|
||||
File tempPath = new File(FileStorageUtils.getTemporalPath(account.name));
|
||||
if (!tempPath.exists()) {
|
||||
assertTrue(tempPath.mkdirs());
|
||||
}
|
||||
|
||||
assertTrue(tempPath.exists());
|
||||
|
||||
createFile("empty.txt", 0);
|
||||
createFile("nonEmpty.txt", 100);
|
||||
createFile("chunkedFile.txt", 500000);
|
||||
}
|
||||
|
||||
protected static File getDummyFile(String name) throws IOException {
|
||||
File file = new File(FileStorageUtils.getTemporalPath(account.name) + File.pathSeparator + name);
|
||||
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
} else {
|
||||
switch (name) {
|
||||
case "empty.txt":
|
||||
return createFile("empty.txt", 0);
|
||||
|
||||
case "nonEmpty.txt":
|
||||
return createFile("nonEmpty.txt", 100);
|
||||
|
||||
case "chunkedFile.txt":
|
||||
return createFile("chunkedFile.txt", 500000);
|
||||
|
||||
default:
|
||||
return createFile(name, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static File createFile(String name, int iteration) throws IOException {
|
||||
File file = new File(FileStorageUtils.getSavePath(account.name) + File.separator + name);
|
||||
File tempPath = new File(FileStorageUtils.getTemporalPath(account.name));
|
||||
if (!tempPath.exists()) {
|
||||
assertTrue(tempPath.mkdirs());
|
||||
}
|
||||
|
||||
File file = new File(FileStorageUtils.getTemporalPath(account.name) + File.separator + name);
|
||||
file.createNewFile();
|
||||
|
||||
FileWriter writer = new FileWriter(file);
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.nextcloud.client.device.PowerManagementService;
|
|||
import com.nextcloud.client.network.Connectivity;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
|
@ -29,7 +30,6 @@ import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
|
|||
import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
import com.owncloud.android.operations.RefreshFolderOperation;
|
||||
import com.owncloud.android.operations.UploadFileOperation;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
|
@ -43,6 +43,7 @@ import java.io.IOException;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
|
@ -139,14 +140,6 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
|||
}
|
||||
}
|
||||
|
||||
private static void createDummyFiles() throws IOException {
|
||||
new File(FileStorageUtils.getSavePath(account.name)).mkdirs();
|
||||
|
||||
createFile("empty.txt", 0);
|
||||
createFile("nonEmpty.txt", 100);
|
||||
createFile("chunkedFile.txt", 500000);
|
||||
}
|
||||
|
||||
private static void waitForServer(OwnCloudClient client, Uri baseUrl) {
|
||||
GetMethod get = new GetMethod(baseUrl + "/status.php");
|
||||
|
||||
|
@ -170,6 +163,10 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
|||
}
|
||||
|
||||
public void uploadOCUpload(OCUpload ocUpload) {
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_COPY);
|
||||
}
|
||||
|
||||
public void uploadOCUpload(OCUpload ocUpload, int localBehaviour) {
|
||||
ConnectivityService connectivityServiceMock = new ConnectivityService() {
|
||||
@Override
|
||||
public boolean isInternetWalled() {
|
||||
|
@ -212,7 +209,7 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
|||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
localBehaviour,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
|
@ -225,11 +222,19 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
|||
|
||||
RemoteOperationResult result = newUpload.execute(client, getStorageManager());
|
||||
assertTrue(result.getLogMessage(), result.isSuccess());
|
||||
//
|
||||
// shortSleep();
|
||||
// shortSleep();
|
||||
//
|
||||
// assertNotNull(getStorageManager().getFileByDecryptedRemotePath(ocUpload.getRemotePath()).getRemoteId());
|
||||
|
||||
OCFile parentFolder = getStorageManager()
|
||||
.getFileByEncryptedRemotePath(new File(ocUpload.getRemotePath()).getParent() + "/");
|
||||
String uploadedFileName = new File(ocUpload.getRemotePath()).getName();
|
||||
OCFile uploadedFile = getStorageManager().
|
||||
getFileByDecryptedRemotePath(parentFolder.getDecryptedRemotePath() + uploadedFileName);
|
||||
|
||||
assertNotNull(uploadedFile.getRemoteId());
|
||||
|
||||
if (localBehaviour == FileUploader.LOCAL_BEHAVIOUR_COPY ||
|
||||
localBehaviour == FileUploader.LOCAL_BEHAVIOUR_MOVE) {
|
||||
assertTrue(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
}
|
||||
|
||||
protected void refreshFolder(String path) {
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
* Copyright (C) 2020 Chris Narkiewicz <hello@ezaquarii.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.operations.DownloadFileOperation;
|
||||
import com.owncloud.android.operations.RefreshFolderOperation;
|
||||
import com.owncloud.android.operations.RemoveFileOperation;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests related to file uploads
|
||||
*/
|
||||
|
||||
public class DownloadIT extends AbstractOnServerIT {
|
||||
private static final String FOLDER = "/testUpload/";
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
RemoteOperationResult result = new RefreshFolderOperation(getStorageManager().getFileByPath("/"),
|
||||
System.currentTimeMillis() / 1000L,
|
||||
false,
|
||||
true,
|
||||
getStorageManager(),
|
||||
account,
|
||||
targetContext)
|
||||
.execute(client);
|
||||
|
||||
// cleanup only if folder exists
|
||||
if (result.isSuccess() && getStorageManager().getFileByDecryptedRemotePath(FOLDER) != null) {
|
||||
new RemoveFileOperation(getStorageManager().getFileByDecryptedRemotePath(FOLDER),
|
||||
false,
|
||||
account,
|
||||
false,
|
||||
targetContext)
|
||||
.execute(client, getStorageManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyDownload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
FOLDER + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload);
|
||||
|
||||
OCUpload ocUpload2 = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
FOLDER + "nonEmpty2.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload2);
|
||||
|
||||
refreshFolder("/");
|
||||
refreshFolder(FOLDER);
|
||||
|
||||
OCFile file1 = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty.txt");
|
||||
OCFile file2 = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty2.txt");
|
||||
verifyDownload(file1, file2);
|
||||
|
||||
assertTrue(new DownloadFileOperation(account, file1, targetContext).execute(client).isSuccess());
|
||||
assertTrue(new DownloadFileOperation(account, file2, targetContext).execute(client).isSuccess());
|
||||
|
||||
refreshFolder(FOLDER);
|
||||
|
||||
file1 = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty.txt");
|
||||
file2 = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty2.txt");
|
||||
|
||||
verifyDownload(file1, file2);
|
||||
}
|
||||
|
||||
private void verifyDownload(OCFile file1, OCFile file2) {
|
||||
assertNotNull(file1);
|
||||
assertNotNull(file2);
|
||||
assertNotSame(file1.getStoragePath(), file2.getStoragePath());
|
||||
|
||||
assertTrue(new File(file1.getStoragePath()).exists());
|
||||
assertTrue(new File(file2.getStoragePath()).exists());
|
||||
|
||||
// test against hardcoded path to make sure that it is correct
|
||||
assertEquals("/storage/emulated/0/Android/media/com.nextcloud.client/nextcloud/" +
|
||||
Uri.encode(account.name, "@") + "/testUpload/nonEmpty.txt",
|
||||
file1.getStoragePath());
|
||||
assertEquals("/storage/emulated/0/Android/media/com.nextcloud.client/nextcloud/" +
|
||||
Uri.encode(account.name, "@") + "/testUpload/nonEmpty2.txt",
|
||||
file2.getStoragePath());
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ import com.nextcloud.client.device.BatteryStatus;
|
|||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.client.network.Connectivity;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
|
@ -36,10 +37,15 @@ import com.owncloud.android.operations.UploadFileOperation;
|
|||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
|
@ -84,6 +90,12 @@ public class UploadIT extends AbstractOnServerIT {
|
|||
}
|
||||
};
|
||||
|
||||
@Before
|
||||
public void before() throws IOException {
|
||||
// make sure that every file is available, even after tests that remove source file
|
||||
createDummyFiles();
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
RemoteOperationResult result = new RefreshFolderOperation(getStorageManager().getFileByPath("/"),
|
||||
|
@ -108,7 +120,7 @@ public class UploadIT extends AbstractOnServerIT {
|
|||
|
||||
@Test
|
||||
public void testEmptyUpload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/empty.txt",
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/empty.txt",
|
||||
FOLDER + "empty.txt",
|
||||
account.name);
|
||||
|
||||
|
@ -117,54 +129,95 @@ public class UploadIT extends AbstractOnServerIT {
|
|||
|
||||
@Test
|
||||
public void testNonEmptyUpload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt",
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
FOLDER + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithCopy() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
FOLDER + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_COPY);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty.txt");
|
||||
|
||||
assertTrue(originalFile.exists());
|
||||
assertTrue(new File(uploadedFile.getStoragePath()).exists());
|
||||
verifyStoragePath(uploadedFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithMove() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
FOLDER + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_MOVE);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty.txt");
|
||||
|
||||
assertFalse(originalFile.exists());
|
||||
assertTrue(new File(uploadedFile.getStoragePath()).exists());
|
||||
verifyStoragePath(uploadedFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithForget() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
FOLDER + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_FORGET);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty.txt");
|
||||
|
||||
assertTrue(originalFile.exists());
|
||||
assertFalse(new File(uploadedFile.getStoragePath()).exists());
|
||||
assertTrue(uploadedFile.getStoragePath().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithDelete() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
FOLDER + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_DELETE);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty.txt");
|
||||
|
||||
assertFalse(originalFile.exists());
|
||||
assertFalse(new File(uploadedFile.getStoragePath()).exists());
|
||||
assertTrue(uploadedFile.getStoragePath().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChunkedUpload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/chunkedFile.txt",
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/chunkedFile.txt",
|
||||
FOLDER + "chunkedFile.txt", account.name);
|
||||
|
||||
uploadOCUpload(ocUpload);
|
||||
}
|
||||
|
||||
public RemoteOperationResult testUpload(OCUpload ocUpload) {
|
||||
UploadFileOperation newUpload = new UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
user,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
);
|
||||
newUpload.addRenameUploadListener(() -> {
|
||||
// dummy
|
||||
});
|
||||
|
||||
newUpload.setRemoteFolderToBeCreated();
|
||||
|
||||
return newUpload.execute(client, getStorageManager());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadInNonExistingFolder() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/empty.txt",
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/empty.txt",
|
||||
FOLDER + "2/3/4/1.txt", account.name);
|
||||
|
||||
uploadOCUpload(ocUpload);
|
||||
}
|
||||
@Test
|
||||
public void testUploadOnChargingOnlyButNotCharging() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/empty.txt",
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/empty.txt",
|
||||
FOLDER + "notCharging.txt", account.name);
|
||||
ocUpload.setWhileChargingOnly(true);
|
||||
|
||||
|
@ -210,7 +263,7 @@ public class UploadIT extends AbstractOnServerIT {
|
|||
}
|
||||
};
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/empty.txt",
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/empty.txt",
|
||||
FOLDER + "charging.txt", account.name);
|
||||
ocUpload.setWhileChargingOnly(true);
|
||||
|
||||
|
@ -249,7 +302,7 @@ public class UploadIT extends AbstractOnServerIT {
|
|||
return new Connectivity(true, false, false, true);
|
||||
}
|
||||
};
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/empty.txt",
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/empty.txt",
|
||||
FOLDER + "noWifi.txt", account.name);
|
||||
ocUpload.setUseWifiOnly(true);
|
||||
|
||||
|
@ -277,7 +330,7 @@ public class UploadIT extends AbstractOnServerIT {
|
|||
|
||||
@Test
|
||||
public void testUploadOnWifiOnlyAndWifi() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/empty.txt",
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/empty.txt",
|
||||
FOLDER + "wifi.txt", account.name);
|
||||
ocUpload.setWhileChargingOnly(true);
|
||||
|
||||
|
@ -310,4 +363,9 @@ public class UploadIT extends AbstractOnServerIT {
|
|||
targetContext)
|
||||
.execute(client, getStorageManager());
|
||||
}
|
||||
|
||||
private void verifyStoragePath(OCFile file) {
|
||||
assertEquals(FileStorageUtils.getSavePath(account.name) + FOLDER + file.getDecryptedFileName(),
|
||||
file.getStoragePath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,13 +89,13 @@ abstract public class FileDataStorageManagerTest extends AbstractOnServerIT {
|
|||
|
||||
assertTrue(new CreateFolderRemoteOperation("/1/2/", true).execute(client).isSuccess());
|
||||
|
||||
assertTrue(new UploadFileRemoteOperation(FileStorageUtils.getSavePath(account.name) + "/chunkedFile.txt",
|
||||
assertTrue(new UploadFileRemoteOperation(getDummyFile("/chunkedFile.txt").getAbsolutePath(),
|
||||
"/1/1/chunkedFile.txt",
|
||||
"text/plain",
|
||||
String.valueOf(System.currentTimeMillis() / 1000))
|
||||
.execute(client).isSuccess());
|
||||
|
||||
assertTrue(new UploadFileRemoteOperation(FileStorageUtils.getSavePath(account.name) + "/chunkedFile.txt",
|
||||
assertTrue(new UploadFileRemoteOperation(getDummyFile("/chunkedFile.txt").getAbsolutePath(),
|
||||
"/1/1/chunkedFile2.txt",
|
||||
"text/plain",
|
||||
String.valueOf(System.currentTimeMillis() / 1000))
|
||||
|
|
|
@ -35,13 +35,11 @@ import com.owncloud.android.db.OCUpload
|
|||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
import com.owncloud.android.utils.FileStorageUtils.getSavePath
|
||||
import junit.framework.Assert.assertEquals
|
||||
import junit.framework.Assert.assertFalse
|
||||
import junit.framework.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class FileUploaderIT : AbstractOnServerIT() {
|
||||
var uploadsStorageManager: UploadsStorageManager? = null
|
||||
|
@ -74,7 +72,7 @@ class FileUploaderIT : AbstractOnServerIT() {
|
|||
*/
|
||||
@Test
|
||||
fun testKeepLocalAndOverwriteRemote() {
|
||||
val file = File(getSavePath(account.name) + "/chunkedFile.txt")
|
||||
val file = getDummyFile("/chunkedFile.txt")
|
||||
val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(
|
||||
|
@ -101,7 +99,7 @@ class FileUploaderIT : AbstractOnServerIT() {
|
|||
|
||||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val ocUpload2 = OCUpload(getSavePath(account.name) + "/empty.txt", "/testFile.txt", account.name)
|
||||
val ocUpload2 = OCUpload(getDummyFile("/empty.txt").absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(
|
||||
UploadFileOperation(
|
||||
|
@ -132,7 +130,7 @@ class FileUploaderIT : AbstractOnServerIT() {
|
|||
*/
|
||||
@Test
|
||||
fun testKeepLocalAndOverwriteRemoteStatic() {
|
||||
val file = File(getSavePath(account.name) + "/chunkedFile.txt")
|
||||
val file = getDummyFile("/chunkedFile.txt")
|
||||
|
||||
FileUploader.uploadNewFile(
|
||||
targetContext,
|
||||
|
@ -156,7 +154,7 @@ class FileUploaderIT : AbstractOnServerIT() {
|
|||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val ocFile2 = OCFile("/testFile.txt")
|
||||
ocFile2.setStoragePath(getSavePath(account.name) + "/empty.txt")
|
||||
ocFile2.setStoragePath(getDummyFile("/empty.txt").absolutePath)
|
||||
|
||||
FileUploader.uploadUpdateFile(
|
||||
targetContext,
|
||||
|
@ -181,7 +179,7 @@ class FileUploaderIT : AbstractOnServerIT() {
|
|||
fun testKeepBoth() {
|
||||
var renameListenerWasTriggered = false
|
||||
|
||||
val file = File(getSavePath(account.name) + "/chunkedFile.txt")
|
||||
val file = getDummyFile("/chunkedFile.txt")
|
||||
val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(
|
||||
|
@ -208,7 +206,7 @@ class FileUploaderIT : AbstractOnServerIT() {
|
|||
|
||||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val file2 = File(getSavePath(account.name) + "/empty.txt")
|
||||
val file2 = getDummyFile("empty.txt")
|
||||
val ocUpload2 = OCUpload(file2.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(
|
||||
|
@ -249,7 +247,7 @@ class FileUploaderIT : AbstractOnServerIT() {
|
|||
*/
|
||||
@Test
|
||||
fun testKeepBothStatic() {
|
||||
val file = File(getSavePath(account.name) + "/chunkedFile.txt")
|
||||
val file = getDummyFile("/chunkedFile.txt")
|
||||
|
||||
FileUploader.uploadNewFile(
|
||||
targetContext,
|
||||
|
@ -273,7 +271,7 @@ class FileUploaderIT : AbstractOnServerIT() {
|
|||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val ocFile2 = OCFile("/testFile.txt")
|
||||
ocFile2.setStoragePath(getSavePath(account.name) + "/empty.txt")
|
||||
ocFile2.setStoragePath(getDummyFile("/empty.txt").absolutePath)
|
||||
|
||||
FileUploader.uploadUpdateFile(
|
||||
targetContext,
|
||||
|
@ -301,7 +299,7 @@ class FileUploaderIT : AbstractOnServerIT() {
|
|||
*/
|
||||
@Test
|
||||
fun testKeepServer() {
|
||||
val file = File(getSavePath(account.name) + "/chunkedFile.txt")
|
||||
val file = getDummyFile("/chunkedFile.txt")
|
||||
val ocUpload = OCUpload(file.absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertTrue(
|
||||
|
@ -328,7 +326,7 @@ class FileUploaderIT : AbstractOnServerIT() {
|
|||
|
||||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val ocUpload2 = OCUpload(getSavePath(account.name) + "/empty.txt", "/testFile.txt", account.name)
|
||||
val ocUpload2 = OCUpload(getDummyFile("/empty.txt").absolutePath, "/testFile.txt", account.name)
|
||||
|
||||
assertFalse(
|
||||
UploadFileOperation(
|
||||
|
@ -358,7 +356,7 @@ class FileUploaderIT : AbstractOnServerIT() {
|
|||
*/
|
||||
@Test
|
||||
fun testKeepServerStatic() {
|
||||
val file = File(getSavePath(account.name) + "/chunkedFile.txt")
|
||||
val file = getDummyFile("/chunkedFile.txt")
|
||||
|
||||
FileUploader.uploadNewFile(
|
||||
targetContext,
|
||||
|
@ -382,7 +380,7 @@ class FileUploaderIT : AbstractOnServerIT() {
|
|||
assertEquals(file.length(), (result.data[0] as RemoteFile).length)
|
||||
|
||||
val ocFile2 = OCFile("/testFile.txt")
|
||||
ocFile2.setStoragePath(getSavePath(account.name) + "/empty.txt")
|
||||
ocFile2.setStoragePath(getDummyFile("/empty.txt").absolutePath)
|
||||
|
||||
FileUploader.uploadUpdateFile(
|
||||
targetContext,
|
||||
|
|
|
@ -25,10 +25,11 @@ package com.owncloud.android.operations;
|
|||
import com.owncloud.android.AbstractOnServerIT;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
|
@ -65,10 +66,10 @@ public class RemoveFileOperationIT extends AbstractOnServerIT {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void deleteFile() {
|
||||
public void deleteFile() throws IOException {
|
||||
String parent = "/test/";
|
||||
String path = parent + "empty.txt";
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/empty.txt", path, account.name);
|
||||
OCUpload ocUpload = new OCUpload(getDummyFile("/empty.txt").getAbsolutePath(), path, account.name);
|
||||
|
||||
uploadOCUpload(ocUpload);
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ import com.owncloud.android.operations.CreateFolderOperation
|
|||
import com.owncloud.android.operations.RefreshFolderOperation
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import junit.framework.TestCase
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
|
@ -92,7 +91,7 @@ class OCFileListFragmentIT : AbstractOnServerIT() {
|
|||
assertTrue(CreateFolderOperation("/test/", user, targetContext).execute(client, storageManager).isSuccess)
|
||||
|
||||
val ocUpload = OCUpload(
|
||||
FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt",
|
||||
getDummyFile("/nonEmpty.txt").absolutePath,
|
||||
"/test/Readme.md",
|
||||
account.name
|
||||
)
|
||||
|
|
|
@ -27,7 +27,6 @@ import android.Manifest;
|
|||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
||||
import org.junit.Rule;
|
||||
|
@ -50,12 +49,12 @@ public class PreviewTextFileFragmentTest extends AbstractIT {
|
|||
|
||||
@Test
|
||||
// @ScreenshotTest // todo run without real server
|
||||
public void displaySimpleTextFile() {
|
||||
public void displaySimpleTextFile() throws IOException {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
shortSleep();
|
||||
|
||||
File file = new File(FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt");
|
||||
File file = getDummyFile("nonEmpty.txt");
|
||||
OCFile test = new OCFile("/text.md");
|
||||
test.setMimeType(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN);
|
||||
test.setStoragePath(file.getAbsolutePath());
|
||||
|
|
|
@ -475,6 +475,7 @@ public class UploadFileOperation extends SyncOperation {
|
|||
return collisionResult;
|
||||
}
|
||||
|
||||
mFile.setDecryptedRemotePath(parentFile.getDecryptedRemotePath() + originalFile.getName());
|
||||
String expectedPath = FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), mFile);
|
||||
expectedFile = new File(expectedPath);
|
||||
|
||||
|
@ -794,10 +795,14 @@ public class UploadFileOperation extends SyncOperation {
|
|||
mFile.getRemotePath(),
|
||||
mFile.getMimeType(),
|
||||
mFile.getEtagInConflict(),
|
||||
timeStamp, onWifiConnection);
|
||||
timeStamp,
|
||||
onWifiConnection);
|
||||
} else {
|
||||
mUploadOperation = new UploadFileRemoteOperation(mFile.getStoragePath(),
|
||||
mFile.getRemotePath(), mFile.getMimeType(), mFile.getEtagInConflict(), timeStamp);
|
||||
mFile.getRemotePath(),
|
||||
mFile.getMimeType(),
|
||||
mFile.getEtagInConflict(),
|
||||
timeStamp);
|
||||
}
|
||||
|
||||
for (OnDatatransferProgressListener mDataTransferListener : mDataTransferListeners) {
|
||||
|
@ -932,7 +937,9 @@ public class UploadFileOperation extends SyncOperation {
|
|||
return null;
|
||||
}
|
||||
|
||||
private void handleSuccessfulUpload(File temporalFile, File expectedFile, File originalFile,
|
||||
private void handleSuccessfulUpload(File temporalFile,
|
||||
File expectedFile,
|
||||
File originalFile,
|
||||
OwnCloudClient client) {
|
||||
switch (mLocalBehaviour) {
|
||||
case FileUploader.LOCAL_BEHAVIOUR_FORGET:
|
||||
|
@ -955,6 +962,12 @@ public class UploadFileOperation extends SyncOperation {
|
|||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, e.getMessage());
|
||||
}
|
||||
} else if (originalFile != null) {
|
||||
try {
|
||||
copy(originalFile, expectedFile);
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, e.getMessage());
|
||||
}
|
||||
}
|
||||
mFile.setStoragePath(expectedFile.getAbsolutePath());
|
||||
saveUploadedFile(client);
|
||||
|
|
Loading…
Reference in New Issue