Skip to content
Merged
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 @@ -1513,24 +1513,28 @@ public void onReceive(Context context, Intent intent) {
}

boolean uploadWasFine = intent.getBooleanExtra(FileUploadWorker.EXTRA_UPLOAD_RESULT, false);
boolean renamedInUpload = getFile().getRemotePath().equals(intent.getStringExtra(FileUploadWorker.EXTRA_OLD_REMOTE_PATH));

boolean sameFile = getFile().getRemotePath().equals(uploadedRemotePath) || renamedInUpload;
Fragment details = getLeftFragment();
boolean renamedInUpload = false;
boolean sameFile = false;
if (getFile() != null) {
renamedInUpload = getFile().getRemotePath().equals(intent.getStringExtra(FileUploadWorker.EXTRA_OLD_REMOTE_PATH));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
renamedInUpload = getFile().getRemotePath().equals(intent.getStringExtra(FileUploadWorker.EXTRA_OLD_REMOTE_PATH));
renamedInUpload = Objects.equals(getFile().getRemotePath(), intent.getStringExtra(FileUploadWorker.EXTRA_OLD_REMOTE_PATH));

Never rely on chaining equals unless you're absolutely sure one if it won't be null

sameFile = getFile().getRemotePath().equals(uploadedRemotePath) || renamedInUpload;
}

if (sameAccount && sameFile && details instanceof FileDetailFragment) {
if (sameAccount && sameFile && getLeftFragment() instanceof FileDetailFragment fileDetailFragment) {
if (uploadWasFine) {
setFile(getStorageManager().getFileByPath(uploadedRemotePath));
} else {
//TODO remove upload progress bar after upload failed.
Log_OC.d(TAG, "Remove upload progress bar after upload failed");
}
if (renamedInUpload) {
if (renamedInUpload && !TextUtils.isEmpty(uploadedRemotePath)) {
String newName = new File(uploadedRemotePath).getName();
DisplayUtils.showSnackMessage(getActivity(), R.string.filedetails_renamed_in_upload_msg, newName);
}
if (uploadWasFine || getFile().fileExists()) {
((FileDetailFragment) details).updateFileDetails(false, true);

if (uploadWasFine || getFile() != null && getFile().fileExists()) {
fileDetailFragment.updateFileDetails(false, true);
} else {
onBackPressed();
}
Expand All @@ -1546,6 +1550,7 @@ public void onReceive(Context context, Intent intent) {
// TODO what about other kind of previews?
}
}

OCFileListFragment ocFileListFragment = getListOfFilesFragment();
if (ocFileListFragment != null) {
ocFileListFragment.setLoading(false);
Expand Down
Loading