Repository navigation
Cleanup part file after upload exception - #17189
Conversation
|
Added some unit tests for small files. Also there are no unit tests for big file chunking, so testing exceptions and part files there will be difficult. |
|
But one cool thing is how I'm taking PHPUnit mocks to the next level: https://github.com/owncloud/core/pull/17189/files#diff-06f023f104a1314e2e8fdfebf767e963R51 😉 |
|
Raised #17220 to refactor exception handling. |
There was a problem hiding this comment.
hmm - this kind of cries already for the 'global' exception handling/conversion function .... 🙊
refs #17220
There was a problem hiding this comment.
I should patent my Base.php idea:
<?php
try {
// All of base.php
} catch (\Exception $e) {
echo "All fine. Nothing to worry about.";
}There was a problem hiding this comment.
Yes it does... but I'm afraid to refactor at this point as we don't have enough test coverage... (and also not enough time)
There was a problem hiding this comment.
Maybe another idea would be to use a shutdown handler to clear part files. This means they need to be registered somewhere to be cleant up later... might be more complicated.
|
Also to note: I'm writing a bit of unit tests for chunking, because without even some base tests it will be impossible to test chunk clearing... |
|
Looks like refactoring will be inevitable: the chunking code path doesn't translate half of the exceptions... I'll limit the refactoring to the specific try/catch blocks that clean up chunks to limit side-effects. |
|
Ok, I added unit test for the file chunking cases and also refactored exception conversion into a method. Please have a look and tell me it's a bit saner now... |
There was a problem hiding this comment.
can you please add the previous exception as third parameter. Makes traces more easy.
There was a problem hiding this comment.
Ok, I'll try and modify all the exception classes to accept a $reason argument.
|
Done: I added the previous exception to the constructors |
|
|
|
Ok, the locking issue seems to be that whenever an exception occurs during the final rename in chunking mode, the part file is not getting unlocked yet. So it's not possible to delete it. Needs further research. |
d2da3ae to
621bebd
Compare
|
Squashed and fixed the unit tests to properly catch the locking exception. I also added a fix for $view->rename to properly unlock the source path (here the part file), so we can delete it after failure: 621bebd |
Added unit tests for checking for stray part files. Convert exception to sabre exception in upload put method. Also added unit test for exception mapping, which also indirectly tests that the part file is being deleted on exception. This applies to both chunking and non-chunking mode. Added some unit tests for chunk upload.
621bebd to
167f57c
Compare
|
A new inspection was created. |
|
Rebased onto master to avoid the class name issue. This is ready for review @MorrisJobke @nickvergessen @icewind1991 @DeepDiver1975 @schiesbn |
|
Looks good 👍 |
There was a problem hiding this comment.
Since we throw an exception right below, we will end up in the catch where we try to re-unlink the file?
There was a problem hiding this comment.
True, missed it. Thanks.
There was a problem hiding this comment.
Ah, the stray lock :)
|
Still works here. There are some additional things I need to debug, but nothing that blocks this and can be done in a followup PR 👍 |
Cleanup part file after upload exception
|
-.- Now github showed my the comments of @nickvergessen |
|
Thanks for merging 😄 I'll send a follow up PR for the small stuff. |
@PVince81 Ping |
|
It's on my internal todo list. Was busy with more important locking stuff yesterday. |
|
Follow up PR here #17268 |

Fixes #17149
@icewind1991 @MorrisJobke
(I haven't tested this yet)