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

(WIP) Attempt to fix hard upload failures during quota events #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joshtrichards
Copy link
Owner

@joshtrichards joshtrichards commented Apr 7, 2023

This is an attempt to fix a backend fail triggered by quota issues while uploading.

Summary

I discovered this while trying to reproduce nextcloud#37578. Technically this may fix that issue as well (it's the same call/code path with a null parameter), but I was only able to reproduce the issue reported there under one condition: if upload would cause the user quota to be exceeded.

In the course of looking into the issue I could reproduce, I came up with this "fix". This area of code is not one I was at all
familiar with previously so I can't say I'd even give a "LGTM" even though I'm the one submitting it. There is an issue, but the best fix may me a variation.

In prepareUpload() the $request->getPath() will contain something like:

  • w/o dirname: uploads/ncadmin/web-file-upload-464f2b6a78f780318dc46e3424dbc0fc-1680893450217 (note it doesn't have the chunk # unlike beforePut())
  • w/ dirname: uploads/ncadmin

Currently we pass the whole thing (1st one) here to prepareUpload() which fails under at least one confirmed scenario (quota exceeded situations).

Without this patch, uploads fail in an ugly way on the backend when the quota is exceeded:

TypeError: OCA\DAV\Upload\ChunkingV2Plugin::getUploadStorage(): Argument #1 ($targetPath) must be of type string, null given, called in /var/www/html/apps/dav/lib/Upload/ChunkingV2Plugin.php on line 285

This is not an issue if the quota isn't triggered. Though, interestingly, $uploadMetadata is always blank

As far as I can tell $uploadMetadata is always null.


uploadPath gets set in prepareUpload()
It gets set to either:
$uploadMetadata[self::UPLOAD_TARGET_PATH] or null

checkPrerequisuites() is called by beforePut() + beforeMove
But not by beforeDelete()
Among other things it checks if uploadPath is null
and throws a PreconditionFailed exception if so:
"Missing metadata for chunked upload"

Since checkPrerequisites() is never called in beforeDelete()...
beforeDelete() happily calls getUploadStorage() with a null...
uploadPath

Observations:

The main way uploadPath ends up null is...
...if $uploadMetadata[self::UPLOAD_TARGET_PATH] isn't set...
...in prepareUpload()...
...which gets $uploadMetadata via...
$this->cache->get($this->uploadFolder->getName());


TODO

  • ...

Checklist

This is an attempt to fix uploading problems that can be triggered by quota issues.

Signed-off-by: Josh Richards <[email protected]>
joshtrichards pushed a commit that referenced this pull request May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant