Merge pull request #2449 from nextcloud/fixNPE

prevent NPE via null check
This commit is contained in:
Andy Scherzinger 2018-04-22 19:50:09 +02:00 committed by GitHub
commit 4ba4341e14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -373,7 +373,7 @@ public class UploadFileOperation extends SyncOperation {
OCFile parent = getStorageManager().getFileByPath(remoteParentPath);
// in case of a fresh upload with subfolder, where parent does not exist yet
if (parent == null && mFolderUnlockToken.isEmpty()) {
if (parent == null && (mFolderUnlockToken == null || mFolderUnlockToken.isEmpty())) {
// try to create folder
RemoteOperationResult result = grantFolderExistence(remoteParentPath, client);
@ -396,7 +396,7 @@ public class UploadFileOperation extends SyncOperation {
// try to unlock folder with stored token, e.g. when upload needs to be resumed or app crashed
// the parent folder should exist as it is a resume of a broken upload
if (!mFolderUnlockToken.isEmpty()) {
if (mFolderUnlockToken != null && !mFolderUnlockToken.isEmpty()) {
UnlockFileOperation unlockFileOperation = new UnlockFileOperation(parent.getLocalId(), mFolderUnlockToken);
RemoteOperationResult unlockFileOperationResult = unlockFileOperation.execute(client, true);