Skip to content

Commit f79c579

Browse files
committed
make missingPermissionThrown atomic to fix: Shared primitive variable "missingPermissionThrown" in one thread may not yield the value of the most recent write from another thread
Signed-off-by: alperozturk <alper_ozturk@proton.me>
1 parent 700e0e0 commit f79c579

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/src/main/java/com/owncloud/android/operations/UploadFileOperation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public class UploadFileOperation extends SyncOperation {
169169

170170
private boolean encryptedAncestor;
171171
private OCFile duplicatedEncryptedFile;
172-
private boolean missingPermissionThrown = false;
172+
private AtomicBoolean missingPermissionThrown = new AtomicBoolean(false);
173173

174174
public static OCFile obtainNewOCFileToUpload(String remotePath, String localPath, String mimeType) {
175175
OCFile newFile = new OCFile(remotePath);
@@ -410,7 +410,7 @@ public Context getContext() {
410410
}
411411

412412
public boolean isMissingPermissionThrown() {
413-
return missingPermissionThrown;
413+
return missingPermissionThrown.get();
414414
}
415415

416416
@Override
@@ -430,7 +430,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
430430
if (!localFile.canRead()) {
431431
Log_OC.e(TAG, "Upload cancelled for " + getStoragePath() + ": file is not readable or inaccessible.");
432432
UploadFileOperationExtensionsKt.showStoragePermissionNotification(this);
433-
missingPermissionThrown = true;
433+
missingPermissionThrown.set(true);
434434
return new RemoteOperationResult<>(new UploadFileException.MissingPermission());
435435
}
436436

0 commit comments

Comments
 (0)