Skip to content

Conversation

@SergioBertolinSG
Copy link
Contributor

This PR will require to remove getFileIdForPath function in Comments after #27446 is merged. Or remove it from there after this PR is merged.

@mention-bot
Copy link

@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.

@PVince81
Copy link
Contributor

This test doesn't match the case from #26992 but seems to have found yet another bug related to MOVE on the new endpoint.

I'll extend this PR to also test #26992

@PVince81
Copy link
Contributor

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...

@PVince81
Copy link
Contributor

Uh oh, it looks like the new Sabre requires destination nodes to implement IMoveTarget: https://github.com/fruux/sabre-dav/blob/3.2.2/lib/DAV/Tree.php#L155

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.

@PVince81
Copy link
Contributor

The IMoveTarget interface already existed since a while, even in stable9.

The reason we didn't have this issue is because on the old endpoint we overrode the move method in our own objecttree.

So the fix here is to either override the ObjectTree for the new DAV endpoint again or implement IMoveTarget. Quickfix is the ObjectTree approach with a proved complex move algorithm.
If we decided to go the IMoveTarget way we need to reimplement that complex algorithm from a different perspective.

@DeepDiver1975 thoughts ?

@PVince81
Copy link
Contributor

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.

@SergioBertolinSG
Copy link
Contributor Author

👍 to the tests changes, I misunderstood the issue.

@PVince81
Copy link
Contributor

@DeepDiver1975 are you investigating this ?

@PVince81
Copy link
Contributor

I've ported (read: copy-pasted) the code from ObjectTree::move into the Sabre Directory node which now implements IMoveTarget: 51b1b1c

This is still experimental. Apparently tests pass and fileid is kept.
Needs more extensive testing.

@PVince81
Copy link
Contributor

PVince81 commented Mar 29, 2017

  • To avoid duplicate code, I suggest to remove ObjectTree::move() completely as this will then trigger the fallback logic that calls Directory::moveInto(). So the logic for old and new endpoints would be exactly the same code.

  • what about "copy" permissions ?

@PVince81
Copy link
Contributor

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.

@PVince81 PVince81 changed the title Added test about checking file id after a move Fix fileid loss on MOVE Mar 29, 2017
@PVince81
Copy link
Contributor

Fixed unit tests by moving them from ObjectTreeTest to DirectoryTest and adjusting.

@SergioBertolinSG
Copy link
Contributor Author

@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
Scenario: Renaming a folder beginning with a backslash encoded should return an error using new endpoint
Scenario: Renaming a folder including a backslash encoded should return an error using new endpoint

@PVince81
Copy link
Contributor

  • rerun perms smashbox tests against new endpoint

@PVince81
Copy link
Contributor

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.

@PVince81
Copy link
Contributor

14:37:59     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA@2/tests/integration/features/checksums.feature:143
14:37:59     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA@2/tests/integration/features/webdav-related.feature:374
14:37:59     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA@2/tests/integration/features/webdav-related.feature:386
14:37:59     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA@2/tests/integration/features/webdav-related.feature:398
14:37:59     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA@2/tests/integration/features/webdav-related.feature:478
14:37:59     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA@2/tests/integration/features/webdav-related.feature:504
14:37:59     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA@2/tests/integration/features/webdav-related.feature:518
14:37:59     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA@2/tests/integration/features/webdav-related.feature:525

@PVince81
Copy link
Contributor

Fixed to accept FutureFile (IFile) to be moved into a Directory instance.
FutureFile isn't an instance of ownCloud's Node class but still a valid file that can be streamed with copy+delete.

This should fix the webdav integration tests at least.

@PVince81
Copy link
Contributor

Less failures now.

19:30:49 --- Failed scenarios:
19:30:49 
19:30:49     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA/tests/integration/features/webdav-related.feature:478
19:30:49     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA/tests/integration/features/webdav-related.feature:504
19:30:49     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA/tests/integration/features/webdav-related.feature:518
19:30:49     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA/tests/integration/features/webdav-related.feature:525

@PVince81
Copy link
Contributor

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 httpMove

@PVince81
Copy link
Contributor

@PVince81
Copy link
Contributor

Added Sabre dodging for FutureFile to prevent deleting the target node.
Fixed integration test about backslashes to really be about backslashes.

I expect all tests to pass now.

@PVince81
Copy link
Contributor

One last bit hopefully:

13:53:04 --- Failed scenarios:
13:53:04 
13:53:04     /var/lib/jenkins/workspace/owncloud-core_core_PR-27508-MESR5CP2N2QXQOWAZONE6PLG33IGBKP2PGDCIAYEVIKNFF7CK7LA/tests/integration/features/webdav-related.feature:525

@PVince81 PVince81 force-pushed the inttest-checking-fileid-new-chunking branch from 1b168bd to 435404b Compare March 30, 2017 12:00
@PVince81
Copy link
Contributor

Ok, apparently I missed fixing a test.

NOW all tests shall pass

@PVince81
Copy link
Contributor

@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) {
Copy link
Member

Choose a reason for hiding this comment

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

Are directories included?

Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

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

indentation

Copy link
Contributor

Choose a reason for hiding this comment

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

who stole my tab?

Copy link
Contributor

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

@jvillafanez
Copy link
Member

Some questions:

  • Sabre/Directory uses a moveInto function. Is there a move function (maybe inherited) that could be being used? How the directories will be moved?
  • I think there is a Sabe/File file... Is move a possible action there (I guess files can be moved)? What method would be called?
  • There is $this->tree->move($path, $destination); call in the beforeMoveFutureFile... if the Sabre/ObjectTree move method has been removed, how it will be handled?

I'm not used to this part of the code, so I'm a bit lost here.

@PVince81
Copy link
Contributor

PVince81 commented Apr 6, 2017

Thanks for the review.

Sabre/Directory uses a moveInto function. Is there a move function (maybe inherited) that could be being used? How the directories will be moved?

Directories are moved also through this function.
Normally if you don't implement moveInto from the IMoveTarget interface, it's the Sabre Tree that does a move by actually doing a copy+delete: https://github.com/fruux/sabre-dav/blob/master/lib/DAV/Tree.php#L158 (see a few lines down).

I think there is a Sabe/File file... Is move a possible action there (I guess files can be moved)? What method would be called?

There is no move function on Sabre nodes at all, neither files (IFile) nor directories (ICollection). This is all handled by the Tree Sabre class. In the old endpoint we override Tree::move but the new endpoint cannot use overriding any more because files are only a subtree of the whole DAV tree. For the old endpoint the file tree was the full tree.

There is $this->tree->move($path, $destination); call in the beforeMoveFutureFile... if the Sabre/ObjectTree move method has been removed, how it will be handled?

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 IFutureFile (which is not a real file so cannot really be moved)

@jvillafanez
Copy link
Member

Ok, it make sense now.

Taking into account the moveInto function has been copied from another place, I'm not going to complain about that (now).

I haven't tested, but 👍 for the code.

@PVince81
Copy link
Contributor

PVince81 commented Apr 6, 2017

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.

@PVince81 PVince81 merged commit 78685c2 into master Apr 6, 2017
@PVince81 PVince81 deleted the inttest-checking-fileid-new-chunking branch April 6, 2017 13:30
@PVince81
Copy link
Contributor

PVince81 commented Apr 7, 2017

We might want to backport this to stable9.1 (and stable9?) where the new endpoint already existed but isn't used yet

@PVince81
Copy link
Contributor

Regression: #30325

@lock
Copy link

lock bot commented Aug 1, 2019

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.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants