Skip to content

Commit

Permalink
Merge pull request #12794 from nextcloud/Bugfix/upload-and-download-p…
Browse files Browse the repository at this point in the history
…roblems

Fix upload download problems
  • Loading branch information
tobiasKaminsky authored Apr 4, 2024
2 parents 807a865 + 11c24e6 commit 39c80a5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ class OfflineSyncWork constructor(
* @return new etag if changed, `null` otherwise
*/
private fun checkEtagChanged(folderName: String, storageManager: FileDataStorageManager, user: User): String? {
val ocFolder = storageManager.getFileByPath(folderName)
Log_OC.d(TAG, folderName + ": currentEtag: " + ocFolder.etag)
val ocFolder = storageManager.getFileByPath(folderName) ?: return null

Log_OC.d(TAG, "$folderName: currentEtag: ${ocFolder.etag}")

// check for etag change, if false, skip
val checkEtagOperation = CheckEtagRemoteOperation(
ocFolder.remotePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class FileDownloadHelper {
val fileStorageManager = FileDataStorageManager(user, MainApp.getAppContext().contentResolver)
val topParentId = fileStorageManager.getTopParentId(file)

return if (file.isFolder) {
backgroundJobManager.isStartFileDownloadJobScheduled(user, file.fileId) ||
backgroundJobManager.isStartFileDownloadJobScheduled(user, topParentId)
val isJobScheduled = backgroundJobManager.isStartFileDownloadJobScheduled(user, file.fileId)
return isJobScheduled || if (file.isFolder) {
backgroundJobManager.isStartFileDownloadJobScheduled(user, topParentId)
} else {
FileDownloadWorker.isDownloading(user.accountName, file.fileId)
}
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/java/com/owncloud/android/datamodel/OCFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,6 @@ public boolean existsOnDevice() {
return false;
}

public String getFileNameWithoutExtension(String fileName) {
int dotIndex = fileName.lastIndexOf('.');
if (dotIndex > 0) {
return fileName.substring(0, dotIndex);
} else {
return fileName;
}
}

/**
* The path, where the file is stored locally
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,14 @@ protected RemoteOperationResult run(OwnCloudClient client) {
}
}

if (downloadType == DownloadType.EXPORT) {
if (downloadType == DownloadType.DOWNLOAD && !file.isEncrypted()) {
moved = tmpFile.renameTo(newFile);
boolean isLastModifiedSet = newFile.setLastModified(file.getModificationTimestamp());
Log_OC.d(TAG, "Last modified set: " + isLastModifiedSet);
if (!moved) {
result = new RemoteOperationResult(RemoteOperationResult.ResultCode.LOCAL_STORAGE_NOT_MOVED);
}
} else if (downloadType == DownloadType.EXPORT) {
new FileExportUtils().exportFile(file.getFileName(),
file.getMimeType(),
operationContext.getContentResolver(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ private RemoteOperationResult encryptedUpload(OwnCloudClient client, OCFile pare
metadata,
token,
client,
metadataExists,
true,
mContext,
user,
getStorageManager());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ public static RemoveFilesDialogFragment newInstance(ArrayList<OCFile> files) {

if (containsFolder || containsDown) {
args.putInt(ARG_NEGATIVE_BTN_RES, R.string.confirmation_remove_local);
args.putInt(ARG_NEUTRAL_BTN_RES, R.string.file_keep);
} else {
args.putInt(ARG_NEGATIVE_BTN_RES, R.string.file_keep);
}

args.putInt(ARG_NEUTRAL_BTN_RES, R.string.file_keep);
args.putParcelableArrayList(ARG_TARGET_FILES, files);
frag.setArguments(args);

Expand Down

0 comments on commit 39c80a5

Please sign in to comment.