Skip to content

Commit cd4f0c3

Browse files
committed
fix(synchronize-folder-operation): local folder npe
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
1 parent 1d93966 commit cd4f0c3

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ protected RemoteOperationResult run(OwnCloudClient client) {
126126
try {
127127
// get locally cached information about folder
128128
mLocalFolder = getStorageManager().getFileByPath(mRemotePath);
129+
if (mLocalFolder == null) {
130+
Log_OC.e(TAG, "Local folder is null, cannot run synchronize folder operation, remote path: " + mRemotePath);
131+
return new RemoteOperationResult<>(ResultCode.FILE_NOT_FOUND);
132+
}
129133

130134
result = checkForChanges(client);
131135

@@ -163,18 +167,17 @@ private RemoteOperationResult checkForChanges(OwnCloudClient client) throws Oper
163167

164168
// remote request
165169
ReadFileRemoteOperation operation = new ReadFileRemoteOperation(mRemotePath);
166-
RemoteOperationResult result = operation.execute(client);
167-
if (result.isSuccess()) {
168-
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
170+
var result = operation.execute(client);
171+
if (result.isSuccess() && result.getData().get(0) instanceof RemoteFile remoteFile) {
172+
OCFile remoteFolder = FileStorageUtils.fillOCFile(remoteFile);
169173

170174
// check if remote and local folder are different
171175
mRemoteFolderChanged = !(remoteFolder.getEtag().equalsIgnoreCase(mLocalFolder.getEtag()));
172176

173-
result = new RemoteOperationResult(ResultCode.OK);
177+
result = new RemoteOperationResult<>(ResultCode.OK);
174178

175179
Log_OC.i(TAG, "Checked " + user.getAccountName() + mRemotePath + " : " +
176-
(mRemoteFolderChanged ? "changed" : "not changed"));
177-
180+
(mRemoteFolderChanged ? "changed" : "not changed"));
178181
} else {
179182
// check failed
180183
if (result.getCode() == ResultCode.FILE_NOT_FOUND) {

0 commit comments

Comments
 (0)