Use dav versions in files#29257
Conversation
878c833 to
52cdaa2
Compare
PVince81
left a comment
There was a problem hiding this comment.
Looks good so far.
I didn't remember seeing tests for the new Sabre nodes, please add some. (I expect codecov will complain about this).
Can you clarify the part about Webdav COPY vs $storage->restoreVersion. If they are connected, does the error message propagate properly when restoring to another file than the original one ? (no HTTP 500).
| use Sabre\HTTP\RequestInterface; | ||
| use Sabre\HTTP\ResponseInterface; | ||
|
|
||
| class CorePlugin extends ServerPlugin { |
There was a problem hiding this comment.
please rename to something that says "plugin to avoid deletion on copy" or something. CorePlugin is the wrong name for this. Also please add PHPDoc to describe this.
| if ($sourceNode instanceof ICopySource) { | ||
| $copySuccess = $sourceNode->copy($destinationNode->getFileInfo()->getPath()); | ||
| } | ||
| if (!$copySuccess) { |
There was a problem hiding this comment.
wouldn't doing a simple return here let the actual CorePlugin do the fallback ? this would remove the need for duplicating the response related code below
There was a problem hiding this comment.
No because the fall back will still perform the delete of the target.
| namespace OCA\DAV\Files; | ||
|
|
||
|
|
||
| interface ICopySource { |
| * @param string $destinationPath | ||
| * @return boolean | ||
| */ | ||
| public function copy($destinationPath); |
There was a problem hiding this comment.
Write a short sentence for the PHPDoc, at least on the interface.
| use OCA\DAV\Files\ICopySource; | ||
| use Sabre\DAV\File; | ||
|
|
||
| class MetaFile extends File implements ICopySource { |
There was a problem hiding this comment.
what's a MetaFile ? => PHPDoc
| * @param {Object} [headers=null] additional headers | ||
| * | ||
| * @return {Promise} promise | ||
| */ |
|
|
||
| public function copy($targetPath) { | ||
| //TODO: inject | ||
| $target = \OC::$server->getRootFolder()->get($targetPath); |
There was a problem hiding this comment.
can we inject the root folder ? (lazy root folder if possible)
|
|
||
| $copySuccess = false; | ||
| if ($sourceNode instanceof ICopySource) { | ||
| $copySuccess = $sourceNode->copy($destinationNode->getFileInfo()->getPath()); |
There was a problem hiding this comment.
Do I understand it correctly that doing a Webdav COPY is not the same as calling $storage->restoreVersion() ?
If it was I'd expect to have some validation to make sure the COPY is operating on the same storage + target file and fail if it doesn't.
There was a problem hiding this comment.
Do I understand it correctly that doing a Webdav COPY is not the same as calling $storage->restoreVersion() ?
within the implementation of copy() restoreVersion() is called if applicable
| /** @var IVersionedStorage | Storage $storage */ | ||
| $versions = $storage->getVersions($internalPath); | ||
| return array_map(function($version) use ($storage, $internalPath) { | ||
| return new MetaFileVersionNode($this, $version['version'],$storage, $internalPath); |
| * Interface IVersionedStorage - storage layer to access version of a file | ||
| * | ||
| * @package OCP\Files\Storage | ||
| * @since 10.1.0 |
There was a problem hiding this comment.
we need to make a decision on this - since no database change is involved we can add this to 10.0.x as well
e40074b to
105d4d4
Compare
2b8e059 to
1ecfc92
Compare
ec59013 to
8654b6c
Compare
|
some known troubles with multiple mounts: #29490 |
8654b6c to
26ec180
Compare
Codecov Report
@@ Coverage Diff @@
## master #29257 +/- ##
============================================
+ Coverage 61.71% 61.76% +0.04%
- Complexity 17482 17501 +19
============================================
Files 1047 1045 -2
Lines 57714 57712 -2
============================================
+ Hits 35619 35644 +25
+ Misses 22095 22068 -27
Continue to review full report at Codecov.
|
26ec180 to
18dd0ef
Compare
|
@PVince81 please review and test - THX |
f959060 to
630b0a0
Compare
| } | ||
|
|
||
|
|
||
| public function testMoveFileIntoSharedFolderAsRecipient() { |
There was a problem hiding this comment.
removed - access to source is checked on the meta node level
| } | ||
|
|
||
|
|
||
| public function testMoveFolderIntoSharedFolderAsRecipient() { |
There was a problem hiding this comment.
removed - access to source is checked on the meta node level
| \OC::$server->getShareManager()->deleteShare($share); | ||
| } | ||
|
|
||
| public function testRenameSharedFile() { |
There was a problem hiding this comment.
removed - access to source is checked on the meta node level
| public function copy($targetPath) { | ||
| $target = $this->root->get($targetPath); | ||
| if ($target instanceof File && $target->getId() === $this->parent->getId()) { | ||
| if (!$target->isUpdateable()) { |
There was a problem hiding this comment.
this is where the write access is verified
| */ | ||
| public static function post_delete($args, $prefix = '') { | ||
| $path = Files\Filesystem::normalizePath($args['path']); | ||
| $user = isset($args['user']) ? $args['user'] : \OC_User::getUser(); |
There was a problem hiding this comment.
the user is now part of the hook arguments to make sure the correct user is used
There was a problem hiding this comment.
Wow, our code can be quite obscure sometimes. I was confused when seeing that you extended the rollback event to include user, but this method is called post_delete.
Turns out that hook registration in base.php is wiring the "rollback" event to the "post_delete_versions" method here.
|
|
||
| $versionCreated = false; | ||
| public static function restoreVersion($uid, $filename, $fileToRestore, $revision) { | ||
| if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) !== true) { |
There was a problem hiding this comment.
old check was against string "true" and you replaced it with boolean true. I hope this won't break existing configs.
Of course, I'd expect the original code to use booleans...
There was a problem hiding this comment.
Storage::DEFAULTENABLED is true and not 'true' and the old code used == and not ===/!==
|
for previews there is a follow up pr - #29319 |
|
@DeepDiver1975 does the follow up solve the problem ? I had the impression that it's a hook related bug when using ext storage + share, since regular scenarios work already. If you intend to fix it in that PR, please add it as checklist item there. |
The whole preview generation will be changed - fixing anything in here is useless work. |
|
Thanks for clarification. I wasn't aware that the DAV previews would also touch the lower levels. Sounds good then. |
|
THX |
|
@DeepDiver1975 can you backport ICopySource to stable10 so we can fix #29561 ? |
|
@DeepDiver1975 regarding the change of this method: |
I see no reason to bump the version. Are you asking to find out about the API change? |
|
ok.
yes, this was the idea behind Edit: formatting |
|
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. |

Description
This PR is based on #29207 and integrated files_versions ui via webdav
Related Issue
#29087
Motivation and Context
We shall use the webdav api for versioning
How Has This Been Tested?
Types of changes
Checklist: