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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
4ffca58b
Commit
4ffca58b
authored
10 years ago
by
Thomas Müller
Browse files
Options
Downloads
Patches
Plain Diff
don't rely on \OCP\User::getUser() - it is not set properly in case of async operations
parent
7cb6811a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/files_trashbin/lib/trashbin.php
+8
-10
8 additions, 10 deletions
apps/files_trashbin/lib/trashbin.php
with
8 additions
and
10 deletions
apps/files_trashbin/lib/trashbin.php
+
8
−
10
View file @
4ffca58b
...
...
@@ -423,7 +423,7 @@ class Trashbin {
if
(
$view
->
is_dir
(
'/files_trashbin/versions/'
.
$file
))
{
$rootView
->
rename
(
\OC\Files\Filesystem
::
normalizePath
(
$user
.
'/files_trashbin/versions/'
.
$file
),
\OC\Files\Filesystem
::
normalizePath
(
$owner
.
'/files_versions/'
.
$ownerPath
));
}
else
if
(
$versions
=
self
::
getVersionsFromTrash
(
$versionedFile
,
$timestamp
))
{
}
else
if
(
$versions
=
self
::
getVersionsFromTrash
(
$versionedFile
,
$timestamp
,
$user
))
{
foreach
(
$versions
as
$v
)
{
if
(
$timestamp
)
{
$rootView
->
rename
(
$user
.
'/files_trashbin/versions/'
.
$versionedFile
.
'.v'
.
$v
.
'.d'
.
$timestamp
,
$owner
.
'/files_versions/'
.
$ownerPath
.
'.v'
.
$v
);
...
...
@@ -527,8 +527,8 @@ class Trashbin {
$file
=
$filename
;
}
$size
+=
self
::
deleteVersions
(
$view
,
$file
,
$filename
,
$timestamp
);
$size
+=
self
::
deleteEncryptionKeys
(
$view
,
$file
,
$filename
,
$timestamp
);
$size
+=
self
::
deleteVersions
(
$view
,
$file
,
$filename
,
$timestamp
,
$user
);
$size
+=
self
::
deleteEncryptionKeys
(
$view
,
$file
,
$filename
,
$timestamp
,
$user
);
if
(
$view
->
is_dir
(
'/files_trashbin/files/'
.
$file
))
{
$size
+=
self
::
calculateSize
(
new
\OC\Files\View
(
'/'
.
$user
.
'/files_trashbin/files/'
.
$file
));
...
...
@@ -549,14 +549,13 @@ class Trashbin {
* @param $timestamp
* @return int
*/
private
static
function
deleteVersions
(
\OC\Files\View
$view
,
$file
,
$filename
,
$timestamp
)
{
private
static
function
deleteVersions
(
\OC\Files\View
$view
,
$file
,
$filename
,
$timestamp
,
$user
)
{
$size
=
0
;
if
(
\OCP\App
::
isEnabled
(
'files_versions'
))
{
$user
=
\OCP\User
::
getUser
();
if
(
$view
->
is_dir
(
'files_trashbin/versions/'
.
$file
))
{
$size
+=
self
::
calculateSize
(
new
\OC\Files\view
(
'/'
.
$user
.
'/files_trashbin/versions/'
.
$file
));
$view
->
unlink
(
'files_trashbin/versions/'
.
$file
);
}
else
if
(
$versions
=
self
::
getVersionsFromTrash
(
$filename
,
$timestamp
))
{
}
else
if
(
$versions
=
self
::
getVersionsFromTrash
(
$filename
,
$timestamp
,
$user
))
{
foreach
(
$versions
as
$v
)
{
if
(
$timestamp
)
{
$size
+=
$view
->
filesize
(
'/files_trashbin/versions/'
.
$filename
.
'.v'
.
$v
.
'.d'
.
$timestamp
);
...
...
@@ -578,10 +577,9 @@ class Trashbin {
* @param $timestamp
* @return int
*/
private
static
function
deleteEncryptionKeys
(
\OC\Files\View
$view
,
$file
,
$filename
,
$timestamp
)
{
private
static
function
deleteEncryptionKeys
(
\OC\Files\View
$view
,
$file
,
$filename
,
$timestamp
,
$user
)
{
$size
=
0
;
if
(
\OCP\App
::
isEnabled
(
'files_encryption'
))
{
$user
=
\OCP\User
::
getUser
();
$keyfiles
=
\OC\Files\Filesystem
::
normalizePath
(
'files_trashbin/keys/'
.
$filename
);
...
...
@@ -823,8 +821,8 @@ class Trashbin {
* @param int $timestamp timestamp when the file was deleted
* @return array
*/
private
static
function
getVersionsFromTrash
(
$filename
,
$timestamp
)
{
$view
=
new
\OC\Files\View
(
'/'
.
\OCP\User
::
getUser
()
.
'/files_trashbin/versions'
);
private
static
function
getVersionsFromTrash
(
$filename
,
$timestamp
,
$user
)
{
$view
=
new
\OC\Files\View
(
'/'
.
$user
.
'/files_trashbin/versions'
);
$versions
=
array
();
//force rescan of versions, local storage may not have updated the cache
...
...
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