-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix fileid loss on MOVE #27508
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 fileid loss on MOVE #27508
Conversation
|
@SergioBertolinSG, thanks for your PR! By analyzing the history of the files in this pull request, we identified @PVince81, @davitol and @DeepDiver1975 to be potential reviewers. |
|
The first test is overkill. No need to upload. Just use the new DAV endpoint and move an existing file into a subdir, its fileid changes... |
|
Uh oh, it looks like the new Sabre requires destination nodes to implement Since we didn't implement this, it falls back to do a copy + delete. A copy will create a new file... Now let's fine out how old this issue is. |
|
The The reason we didn't have this issue is because on the old endpoint we overrode the So the fix here is to either override the ObjectTree for the new DAV endpoint again or implement @DeepDiver1975 thoughts ? |
|
Seems we can't easily reuse our ObjectTree. In the past the root was simply the files. But now the files stuff is embedded inside a sub-sub-collection. |
|
👍 to the tests changes, I misunderstood the issue. |
|
@DeepDiver1975 are you investigating this ? |
|
I've ported (read: copy-pasted) the code from This is still experimental. Apparently tests pass and fileid is kept. |
|
|
Ok, so my last change makes tests fail. Maybe tests need adjusting since the logic is happening somewhere else. I'll move the tests then. |
|
Fixed unit tests by moving them from ObjectTreeTest to DirectoryTest and adjusting. |
|
@PVince81 About my last added tests, These were failing before your commits: Scenario: Renaming a folder including a backslash encoded should return an error using old endpoint |
|
|
smashbox tests for test_sharePermissions ran fine on master and on this branch, with owncloud/pyocclient#191. I suspect that there are permission checks further down the road, so if they're not done on DAV level, they'll be done on View level. The only difference might be the returned exceptions. |
|
|
Fixed to accept FutureFile (IFile) to be moved into a Directory instance. This should fix the webdav integration tests at least. |
|
Less failures now. |
|
New problem: now the MOVE from Sabre that moves the ".file" to the final file is triggering the default Sabre logic which first deletes the target file when it exists: https://github.com/fruux/sabre-dav/blob/3.2.2/lib/DAV/CorePlugin.php#L637 On the old endpoint this did not happen for chunk upload because we never actually did a Webdav MOVE but always used PUT. And the last PUT was internally doing the assembly. Need to think of a better solution than having to rewrite/override |
|
Added Sabre dodging for FutureFile to prevent deleting the target node. I expect all tests to pass now. |
|
One last bit hopefully: |
This removes the duplicated code
Sabre usually deletes the target node on MOVE before proceeding with the actual move operation. This fix prevents this to happen in case the source node is a FutureFile.
1b168bd to
435404b
Compare
|
Ok, apparently I missed fixing a test. NOW all tests shall pass |
|
@jvillafanez @DeepDiver1975 @butonic @guruz please review (yes @guruz the former Sabre master 😉) |
| public function moveInto($targetName, $fullSourcePath, INode $sourceNode) { | ||
| if (!$sourceNode instanceof Node) { | ||
| // it's a file of another kind, like FutureFile | ||
| if ($sourceNode instanceof IFile) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are directories included?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah, forget it. They should go through this function.
| } | ||
|
|
||
| // do a move manually, skipping Sabre's default "delete" for existing nodes | ||
| $this->tree->move($path, $destination); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
who stole my tab?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably copied this from the Sabre code which uses spaces and not tabs :-S
|
Some questions:
I'm not used to this part of the code, so I'm a bit lost here. |
|
Thanks for the review.
Directories are moved also through this function.
There is no
The base class takes care of it with a copy+delete: https://github.com/fruux/sabre-dav/blob/master/lib/DAV/Tree.php#L158 For the future file this is the right way because internally it will do a stream copy of the virtual |
|
Ok, it make sense now. Taking into account the I haven't tested, but 👍 for the code. |
|
Thanks. I'll fix then indent and insta-merge. Testing already done mostly through the new integration tests. I also did manual testing which worked fine. |
|
We might want to backport this to stable9.1 (and stable9?) where the new endpoint already existed but isn't used yet |
|
Regression: #30325 |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR will require to remove getFileIdForPath function in Comments after #27446 is merged. Or remove it from there after this PR is merged.