Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error on delete in ChunkingV2Plugin #38100

Merged
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
16 changes: 7 additions & 9 deletions apps/dav/lib/Upload/ChunkingV2Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,15 @@ public function beforeMove($sourcePath, $destination): bool {

public function beforeDelete(RequestInterface $request, ResponseInterface $response) {
try {
$this->prepareUpload($request->getPath());
if (!$this->uploadFolder instanceof UploadFolder) {
return true;
}

[$storage, $storagePath] = $this->getUploadStorage($this->uploadPath);
$storage->cancelChunkedWrite($storagePath, $this->uploadId);
return true;
} catch (NotFound $e) {
$this->prepareUpload(dirname($request->getPath()));
$this->checkPrerequisites();
} catch (StorageInvalidException|BadRequest|NotFound $e) {
return true;
}

[$storage, $storagePath] = $this->getUploadStorage($this->uploadPath);

Check notice

Code scanning / Psalm

PossiblyNullArgument

Argument 1 of OCA\DAV\Upload\ChunkingV2Plugin::getUploadStorage cannot be null, possibly null value provided
Copy link
Contributor

Choose a reason for hiding this comment

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

The test if (!$this->uploadFolder instanceof UploadFolder) { from before is missing, leading to this psalm warning. Please add it back.

I cannot judge the rest I do not understand the change.

Copy link
Member

Choose a reason for hiding this comment

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

that's evaluated in checkPrerequisites()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes correct, is evaluated in checkPrerequisites() function, as the same of other functions

$storage->cancelChunkedWrite($storagePath, $this->uploadId);
return true;
}

/**
Expand Down