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
44d217c4
Commit
44d217c4
authored
11 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
Cache: provide a function to get the permissions of all files in a folder with one query
parent
7c0c6bd7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/files/cache/permissions.php
+19
-0
19 additions, 0 deletions
lib/files/cache/permissions.php
lib/files/view.php
+11
-11
11 additions, 11 deletions
lib/files/view.php
with
30 additions
and
11 deletions
lib/files/cache/permissions.php
+
19
−
0
View file @
44d217c4
...
...
@@ -85,6 +85,25 @@ class Permissions {
return
$filePermissions
;
}
/**
* get the permissions for all files in a folder
*
* @param int $parentId
* @return int[]
*/
public
function
getDirectoryPermissions
(
$parentId
)
{
$query
=
\OC_DB
::
prepare
(
'SELECT `*PREFIX*permissions`.`fileid`, `permissions`
FROM `*PREFIX*permissions` INNER JOIN `*PREFIX*filecache` ON `*PREFIX*permissions`.fileid = `*PREFIX*filecache`.fileid
WHERE `*PREFIX*filecache`.parent = ?'
);
$result
=
$query
->
execute
(
array
(
$parentId
));
$filePermissions
=
array
();
while
(
$row
=
$result
->
fetchRow
())
{
$filePermissions
[
$row
[
'fileid'
]]
=
$row
[
'permissions'
];
}
return
$filePermissions
;
}
/**
* remove the permissions for a file
*
...
...
This diff is collapsed.
Click to expand it.
lib/files/view.php
+
11
−
11
View file @
44d217c4
...
...
@@ -267,7 +267,7 @@ class View {
$absolutePath
=
Filesystem
::
normalizePath
(
$this
->
getAbsolutePath
(
$path
));
if
(
\OC_FileProxy
::
runPreProxies
(
'file_put_contents'
,
$absolutePath
,
$data
)
and
Filesystem
::
isValidPath
(
$path
)
and
!
Filesystem
::
isFileBlacklisted
(
$path
)
and
!
Filesystem
::
isFileBlacklisted
(
$path
)
)
{
$path
=
$this
->
getRelativePath
(
$absolutePath
);
$exists
=
$this
->
file_exists
(
$path
);
...
...
@@ -344,7 +344,7 @@ class View {
\OC_FileProxy
::
runPreProxies
(
'rename'
,
$absolutePath1
,
$absolutePath2
)
and
Filesystem
::
isValidPath
(
$path2
)
and
Filesystem
::
isValidPath
(
$path1
)
and
!
Filesystem
::
isFileBlacklisted
(
$path2
)
and
!
Filesystem
::
isFileBlacklisted
(
$path2
)
)
{
$path1
=
$this
->
getRelativePath
(
$absolutePath1
);
$path2
=
$this
->
getRelativePath
(
$absolutePath2
);
...
...
@@ -371,7 +371,7 @@ class View {
list
(,
$internalPath2
)
=
Filesystem
::
resolvePath
(
$absolutePath2
.
$postFix2
);
if
(
$storage
)
{
$result
=
$storage
->
rename
(
$internalPath1
,
$internalPath2
);
\OC_FileProxy
::
runPostProxies
(
'rename'
,
$absolutePath1
,
$absolutePath2
);
\OC_FileProxy
::
runPostProxies
(
'rename'
,
$absolutePath1
,
$absolutePath2
);
}
else
{
$result
=
false
;
}
...
...
@@ -418,7 +418,7 @@ class View {
\OC_FileProxy
::
runPreProxies
(
'copy'
,
$absolutePath1
,
$absolutePath2
)
and
Filesystem
::
isValidPath
(
$path2
)
and
Filesystem
::
isValidPath
(
$path1
)
and
!
Filesystem
::
isFileBlacklisted
(
$path2
)
and
!
Filesystem
::
isFileBlacklisted
(
$path2
)
)
{
$path1
=
$this
->
getRelativePath
(
$absolutePath1
);
$path2
=
$this
->
getRelativePath
(
$absolutePath2
);
...
...
@@ -632,7 +632,7 @@ class View {
$absolutePath
=
Filesystem
::
normalizePath
(
$this
->
getAbsolutePath
(
$path
));
if
(
\OC_FileProxy
::
runPreProxies
(
$operation
,
$absolutePath
,
$extraParam
)
and
Filesystem
::
isValidPath
(
$path
)
and
!
Filesystem
::
isFileBlacklisted
(
$path
)
and
!
Filesystem
::
isFileBlacklisted
(
$path
)
)
{
$path
=
$this
->
getRelativePath
(
$absolutePath
);
if
(
$path
==
null
)
{
...
...
@@ -760,7 +760,7 @@ class View {
}
}
$data
=
\OC_FileProxy
::
runPostProxies
(
'getFileInfo'
,
$path
,
$data
);
$data
=
\OC_FileProxy
::
runPostProxies
(
'getFileInfo'
,
$path
,
$data
);
return
$data
;
}
...
...
@@ -797,18 +797,18 @@ class View {
}
$files
=
$cache
->
getFolderContents
(
$internalPath
);
//TODO: mimetype_filter
$permissions
=
$permissionsCache
->
getDirectoryPermissions
(
$cache
->
getId
(
$internalPath
));
$ids
=
array
();
foreach
(
$files
as
$i
=>
$file
)
{
$files
[
$i
][
'type'
]
=
$file
[
'mimetype'
]
===
'httpd/unix-directory'
?
'dir'
:
'file'
;
$ids
[]
=
$file
[
'fileid'
];
$permissions
=
$permissionsCache
->
get
(
$file
[
'fileid'
],
$user
);
if
(
$permissions
===
-
1
)
{
$permissions
=
$storage
->
getPermissions
(
$file
[
'path'
]);
$permissionsCache
->
set
(
$file
[
'fileid'
],
$user
,
$permissions
);
if
(
!
isset
(
$permissions
[
$file
[
'fileid'
]]))
{
$permissions
[
$file
[
'fileid'
]]
=
$storage
->
getPermissions
(
$file
[
'path'
]);
$permissionsCache
->
set
(
$file
[
'fileid'
],
$user
,
$permissions
[
$file
[
'fileid'
]]);
}
$files
[
$i
][
'permissions'
]
=
$permissions
;
$files
[
$i
][
'permissions'
]
=
$permissions
[
$file
[
'fileid'
]]
;
}
//add a folder for any mountpoint in this directory and add the sizes of other mountpoints to the folders
...
...
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