Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
70969154
Commit
70969154
authored
11 years ago
by
Björn Schießle
Browse files
Options
Downloads
Patches
Plain Diff
always use oc filesystem for rename operation
parent
89f26915
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/files_encryption/hooks/hooks.php
+17
-34
17 additions, 34 deletions
apps/files_encryption/hooks/hooks.php
apps/files_encryption/lib/helper.php
+24
-0
24 additions, 0 deletions
apps/files_encryption/lib/helper.php
with
41 additions
and
34 deletions
apps/files_encryption/hooks/hooks.php
+
17
−
34
View file @
70969154
...
@@ -464,53 +464,37 @@ class Hooks {
...
@@ -464,53 +464,37 @@ class Hooks {
$newShareKeyPath
=
$ownerNew
.
'/files_encryption/share-keys/'
.
$pathNew
;
$newShareKeyPath
=
$ownerNew
.
'/files_encryption/share-keys/'
.
$pathNew
;
}
}
// add key ext if this is not an folder
// create new key folders if it doesn't exists
if
(
!
$view
->
file_exists
(
dirname
(
$newShareKeyPath
)))
{
$view
->
mkdir
(
dirname
(
$newShareKeyPath
));
}
if
(
!
$view
->
file_exists
(
dirname
(
$newKeyfilePath
)))
{
$view
->
mkdir
(
dirname
(
$newKeyfilePath
));
}
// handle share keys
if
(
!
$view
->
is_dir
(
$oldKeyfilePath
))
{
if
(
!
$view
->
is_dir
(
$oldKeyfilePath
))
{
$oldKeyfilePath
.
=
'.key'
;
$oldKeyfilePath
.
=
'.key'
;
$newKeyfilePath
.
=
'.key'
;
$newKeyfilePath
.
=
'.key'
;
// handle share-keys
// handle share-keys
$localKeyPath
=
$view
->
getLocalFile
(
$oldShareKeyPath
);
$matches
=
Helper
::
findShareKeys
(
$oldShareKeyPath
,
$view
);
$escapedPath
=
Helper
::
escapeGlobPattern
(
$localKeyPath
);
$matches
=
glob
(
$escapedPath
.
'*.shareKey'
);
foreach
(
$matches
as
$src
)
{
foreach
(
$matches
as
$src
)
{
$dst
=
\OC\Files\Filesystem
::
normalizePath
(
str_replace
(
$pathOld
,
$pathNew
,
$src
));
$dst
=
\OC\Files\Filesystem
::
normalizePath
(
str_replace
(
$pathOld
,
$pathNew
,
$src
));
$view
->
rename
(
$src
,
$dst
);
// create destination folder if not exists
if
(
!
file_exists
(
dirname
(
$dst
)))
{
mkdir
(
dirname
(
$dst
),
0750
,
true
);
}
rename
(
$src
,
$dst
);
}
}
}
else
{
}
else
{
// handle share-keys folders
// handle share-keys folders
// create destination folder if not exists
if
(
!
$view
->
file_exists
(
dirname
(
$newShareKeyPath
)))
{
mkdir
(
$view
->
getLocalFile
(
$newShareKeyPath
),
0750
,
true
);
}
$view
->
rename
(
$oldShareKeyPath
,
$newShareKeyPath
);
$view
->
rename
(
$oldShareKeyPath
,
$newShareKeyPath
);
}
}
// Rename keyfile so it isn't orphaned
// Rename keyfile so it isn't orphaned
if
(
$view
->
file_exists
(
$oldKeyfilePath
))
{
if
(
$view
->
file_exists
(
$oldKeyfilePath
))
{
// create destination folder if not exists
if
(
!
$view
->
file_exists
(
dirname
(
$newKeyfilePath
)))
{
mkdir
(
dirname
(
$view
->
getLocalFile
(
$newKeyfilePath
)),
0750
,
true
);
}
$view
->
rename
(
$oldKeyfilePath
,
$newKeyfilePath
);
$view
->
rename
(
$oldKeyfilePath
,
$newKeyfilePath
);
}
}
// build the path to the file
// update share keys
$newPath
=
'/'
.
$ownerNew
.
'/files'
.
$pathNew
;
if
(
$util
->
fixFileSize
(
$newPath
))
{
// get sharing app state
$sharingEnabled
=
\OCP\Share
::
isEnabled
();
$sharingEnabled
=
\OCP\Share
::
isEnabled
();
// get users
// get users
...
@@ -518,7 +502,6 @@ class Hooks {
...
@@ -518,7 +502,6 @@ class Hooks {
// update sharing-keys
// update sharing-keys
$util
->
setSharedFileKeyfiles
(
$session
,
$usersSharing
,
$pathNew
);
$util
->
setSharedFileKeyfiles
(
$session
,
$usersSharing
,
$pathNew
);
}
\OC_FileProxy
::
$enabled
=
$proxyStatus
;
\OC_FileProxy
::
$enabled
=
$proxyStatus
;
}
}
...
...
This diff is collapsed.
Click to expand it.
apps/files_encryption/lib/helper.php
+
24
−
0
View file @
70969154
...
@@ -438,6 +438,30 @@ class Helper {
...
@@ -438,6 +438,30 @@ class Helper {
return
preg_replace
(
'/(\*|\?|\[)/'
,
'[$1]'
,
$path
);
return
preg_replace
(
'/(\*|\?|\[)/'
,
'[$1]'
,
$path
);
}
}
/**
* find all share keys for a given file
* @param string $path to the file
* @param \OC\Files\View $view view, relative to data/
*/
public
static
function
findShareKeys
(
$path
,
$view
)
{
$result
=
array
();
$pathinfo
=
pathinfo
(
$path
);
$dirContent
=
$view
->
opendir
(
$pathinfo
[
'dirname'
]);
if
(
is_resource
(
$dirContent
))
{
while
((
$file
=
readdir
(
$dirContent
))
!==
false
)
{
if
(
!
\OC\Files\Filesystem
::
isIgnoredDir
(
$file
))
{
if
(
preg_match
(
"/"
.
$pathinfo
[
'filename'
]
.
".(.*).shareKey/"
,
$file
))
{
$result
[]
=
$pathinfo
[
'dirname'
]
.
'/'
.
$file
;
}
}
}
closedir
(
$dirContent
);
}
return
$result
;
}
/**
/**
* remember from which file the tmp file (getLocalFile() call) was created
* remember from which file the tmp file (getLocalFile() call) was created
* @param string $tmpFile path of tmp file
* @param string $tmpFile path of tmp 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