-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Use dav versions in files #29257
Use dav versions in files #29257
Conversation
878c833
to
52cdaa2
Compare
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.
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).
apps/dav/lib/DAV/CorePlugin.php
Outdated
use Sabre\HTTP\RequestInterface; | ||
use Sabre\HTTP\ResponseInterface; | ||
|
||
class CorePlugin extends ServerPlugin { |
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.
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.
apps/dav/lib/DAV/CorePlugin.php
Outdated
if ($sourceNode instanceof ICopySource) { | ||
$copySuccess = $sourceNode->copy($destinationNode->getFileInfo()->getPath()); | ||
} | ||
if (!$copySuccess) { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because the fall back will still perform the delete of the target.
apps/dav/lib/Files/ICopySource.php
Outdated
namespace OCA\DAV\Files; | ||
|
||
|
||
interface ICopySource { |
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.
PHPDoc
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.
done
apps/dav/lib/Files/ICopySource.php
Outdated
* @param string $destinationPath | ||
* @return boolean | ||
*/ | ||
public function copy($destinationPath); |
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.
Write a short sentence for the PHPDoc, at least on the interface.
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.
done
apps/dav/lib/Meta/MetaFile.php
Outdated
use OCA\DAV\Files\ICopySource; | ||
use Sabre\DAV\File; | ||
|
||
class MetaFile extends File implements ICopySource { |
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.
what's a MetaFile ? => PHPDoc
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.
done
core/js/files/client.js
Outdated
* @param {Object} [headers=null] additional headers | ||
* | ||
* @return {Promise} promise | ||
*/ |
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.
@since 10.0.4
?
|
||
public function copy($targetPath) { | ||
//TODO: inject | ||
$target = \OC::$server->getRootFolder()->get($targetPath); |
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.
can we inject the root folder ? (lazy root folder if possible)
apps/dav/lib/DAV/CorePlugin.php
Outdated
|
||
$copySuccess = false; | ||
if ($sourceNode instanceof ICopySource) { | ||
$copySuccess = $sourceNode->copy($destinationNode->getFileInfo()->getPath()); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
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.
missing space ],$storage
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so no backports then?
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.
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
@@ -118,57 +118,6 @@ protected function tearDown() { | |||
parent::tearDown(); | |||
} | |||
|
|||
|
|||
public function testMoveFileIntoSharedFolderAsRecipient() { |
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.
removed - access to source is checked on the meta node level
@@ -430,106 +379,6 @@ public function testMoveFolder() { | |||
} | |||
|
|||
|
|||
public function testMoveFolderIntoSharedFolderAsRecipient() { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed - access to source is checked on the meta node level
@@ -102,6 +103,9 @@ public function getContent() { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is where the write access is verified
@@ -1334,8 +1334,9 @@ public static function post_delete_versions($args) { | |||
*/ | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the user is now part of the hook arguments to make sure the correct user is used
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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.
👍
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: