Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
ebe1d3df
Commit
ebe1d3df
authored
10 years ago
by
Björn Schießle
Browse files
Options
Downloads
Patches
Plain Diff
don't move versions if only the mount point was renamed
parent
206cb5ba
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/files_versions/lib/hooks.php
+10
-0
10 additions, 0 deletions
apps/files_versions/lib/hooks.php
apps/files_versions/tests/versions.php
+43
-0
43 additions, 0 deletions
apps/files_versions/tests/versions.php
with
53 additions
and
0 deletions
apps/files_versions/lib/hooks.php
+
10
−
0
View file @
ebe1d3df
...
...
@@ -115,6 +115,16 @@ class Hooks {
public
static
function
pre_renameOrCopy_hook
(
$params
)
{
if
(
\OCP\App
::
isEnabled
(
'files_versions'
))
{
// if we rename a movable mount point, then the versions don't have
// to be renamed
$absOldPath
=
\OC\Files\Filesystem
::
normalizePath
(
'/'
.
\OCP\User
::
getUser
()
.
'/files'
.
$params
[
'oldpath'
]);
$manager
=
\OC\Files\Filesystem
::
getMountManager
();
$mount
=
$manager
->
find
(
$absOldPath
);
$internalPath
=
$mount
->
getInternalPath
(
$absOldPath
);
if
(
$internalPath
===
''
and
$mount
instanceof
\OC\Files\Mount\MoveableMount
)
{
return
;
}
$view
=
new
\OC\Files\View
(
\OCP\User
::
getUser
()
.
'/files'
);
if
(
$view
->
file_exists
(
$params
[
'newpath'
]))
{
Storage
::
store
(
$params
[
'newpath'
]);
...
...
This diff is collapsed.
Click to expand it.
apps/files_versions/tests/versions.php
+
43
−
0
View file @
ebe1d3df
...
...
@@ -288,6 +288,49 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase {
\OC\Files\Filesystem
::
unlink
(
'/folder1/folder2/test.txt'
);
}
function
testRenameSharedFile
()
{
\OC\Files\Filesystem
::
file_put_contents
(
"test.txt"
,
"test file"
);
$fileInfo
=
\OC\Files\Filesystem
::
getFileInfo
(
'test.txt'
);
$t1
=
time
();
// second version is two weeks older, this way we make sure that no
// version will be expired
$t2
=
$t1
-
60
*
60
*
24
*
14
;
$this
->
rootView
->
mkdir
(
self
::
USERS_VERSIONS_ROOT
);
// create some versions
$v1
=
self
::
USERS_VERSIONS_ROOT
.
'/test.txt.v'
.
$t1
;
$v2
=
self
::
USERS_VERSIONS_ROOT
.
'/test.txt.v'
.
$t2
;
// the renamed versions should not exist! Because we only moved the mount point!
$v1Renamed
=
self
::
USERS_VERSIONS_ROOT
.
'/test2.txt.v'
.
$t1
;
$v2Renamed
=
self
::
USERS_VERSIONS_ROOT
.
'/test2.txt.v'
.
$t2
;
$this
->
rootView
->
file_put_contents
(
$v1
,
'version1'
);
$this
->
rootView
->
file_put_contents
(
$v2
,
'version2'
);
\OCP\Share
::
shareItem
(
'file'
,
$fileInfo
[
'fileid'
],
\OCP\Share
::
SHARE_TYPE_USER
,
self
::
TEST_VERSIONS_USER2
,
OCP\PERMISSION_ALL
);
self
::
loginHelper
(
self
::
TEST_VERSIONS_USER2
);
$this
->
assertTrue
(
\OC\Files\Filesystem
::
file_exists
(
'test.txt'
));
// execute rename hook of versions app
\OC\Files\Filesystem
::
rename
(
'test.txt'
,
'test2.txt'
);
self
::
loginHelper
(
self
::
TEST_VERSIONS_USER
);
$this
->
assertTrue
(
$this
->
rootView
->
file_exists
(
$v1
));
$this
->
assertTrue
(
$this
->
rootView
->
file_exists
(
$v2
));
$this
->
assertFalse
(
$this
->
rootView
->
file_exists
(
$v1Renamed
));
$this
->
assertFalse
(
$this
->
rootView
->
file_exists
(
$v2Renamed
));
//cleanup
\OC\Files\Filesystem
::
unlink
(
'/test.txt'
);
}
function
testCopy
()
{
\OC\Files\Filesystem
::
file_put_contents
(
"test.txt"
,
"test file"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment