Merge pull request #12794 from nextcloud/Bugfix/upload-and-download-problems

Fix upload download problems
This commit is contained in:
Tobias Kaminsky 2024-04-04 09:25:09 +02:00 committed by GitHub
commit 39c80a5076
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 17 additions and 19 deletions

View File

@ -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,

View File

@ -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)
}

View File

@ -361,15 +361,6 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
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
*

View File

@ -273,7 +273,14 @@ public class DownloadFileOperation extends RemoteOperation {
}
}
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(),

View File

@ -726,7 +726,7 @@ public class UploadFileOperation extends SyncOperation {
metadata,
token,
client,
metadataExists,
true,
mContext,
user,
getStorageManager());

View File

@ -106,11 +106,9 @@ public class RemoveFilesDialogFragment extends ConfirmationDialogFragment implem
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);