Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.28] Fix upload download problems #12816

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,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
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
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 @@ -274,7 +274,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 @@ -722,7 +722,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
Loading