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
024f4375
Commit
024f4375
authored
13 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
keep encrypted and versioned flag in fscache
parent
b2f2a877
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
db_structure.xml
+16
-0
16 additions, 0 deletions
db_structure.xml
lib/filecache.php
+35
-15
35 additions, 15 deletions
lib/filecache.php
with
51 additions
and
15 deletions
db_structure.xml
+
16
−
0
View file @
024f4375
...
...
@@ -126,6 +126,22 @@
<length>
32
</length>
</field>
<field>
<name>
encrypted
</name>
<type>
integer
</type>
<default>
0
</default>
<notnull>
true
</notnull>
<length>
1
</length>
</field>
<field>
<name>
versioned
</name>
<type>
integer
</type>
<default>
0
</default>
<notnull>
true
</notnull>
<length>
1
</length>
</field>
<index>
<name>
path_index
</name>
<unique>
true
</unique>
...
...
This diff is collapsed.
Click to expand it.
lib/filecache.php
+
35
−
15
View file @
024f4375
...
...
@@ -38,10 +38,12 @@ class OC_FileCache{
* - mtime
* - ctime
* - mimetype
* - encrypted
* - versioned
*/
public
static
function
get
(
$path
){
$path
=
OC_Filesystem
::
getRoot
()
.
$path
;
$query
=
OC_DB
::
prepare
(
'SELECT ctime,mtime,mimetype,size FROM *PREFIX*fscache WHERE path=?'
);
$query
=
OC_DB
::
prepare
(
'SELECT ctime,mtime,mimetype,size
,encrypted,versioned
FROM *PREFIX*fscache WHERE path=?'
);
$result
=
$query
->
execute
(
array
(
$path
))
->
fetchRow
();
if
(
is_array
(
$result
)){
return
$result
;
...
...
@@ -60,19 +62,24 @@ class OC_FileCache{
*/
public
static
function
put
(
$path
,
$data
){
$path
=
OC_Filesystem
::
getRoot
()
.
$path
;
if
(
$id
=
self
::
getFileId
(
$path
)
!=-
1
){
self
::
update
(
$id
,
$data
);
return
;
}
if
(
$path
==
'/'
){
$parent
=-
1
;
}
else
{
$parent
=
self
::
getFileId
(
dirname
(
$path
));
}
$id
=
self
::
getFileId
(
$path
);
if
(
$id
!=-
1
){
self
::
update
(
$id
,
$data
);
return
;
}
if
(
!
isset
(
$data
[
'encrypted'
])){
$data
[
'encrypted'
]
=
false
;
}
if
(
!
isset
(
$data
[
'versioned'
])){
$data
[
'versioned'
]
=
false
;
}
$mimePart
=
dirname
(
$data
[
'mimetype'
]);
$query
=
OC_DB
::
prepare
(
'INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart) VALUES(?,?,?,?,?,?,?,?)'
);
// echo $path;
// print_r($data);
$query
->
execute
(
array
(
$parent
,
basename
(
$path
),
$path
,
$data
[
'size'
],
$data
[
'mtime'
],
$data
[
'ctime'
],
$data
[
'mimetype'
],
$mimePart
));
}
...
...
@@ -83,9 +90,21 @@ class OC_FileCache{
* @param array $data
*/
private
static
function
update
(
$id
,
$data
){
$mimePart
=
dirname
(
$data
[
'mimetype'
]);
$query
=
OC_DB
::
prepare
(
'UPDATE *PREFIX*fscache SET size=? ,mtime=? ,ctime=? ,mimetype=? , mimepart=? WHERE id=?'
);
$query
->
execute
(
array
(
$data
[
'size'
],
$data
[
'mtime'
],
$data
[
'ctime'
],
$data
[
'mimetype'
],
$mimePart
,
$id
));
$arguments
=
array
();
$queryParts
=
array
();
foreach
(
array
(
'size'
,
'mtime'
,
'ctime'
,
'mimetype'
,
'encrypted'
,
'versioned'
)
as
$attribute
){
if
(
isset
(
$data
[
$attribute
])){
$arguments
[]
=
$data
[
$attribute
];
$queryParts
[]
=
$attribute
.
'=?'
;
}
}
if
(
isset
(
$data
[
'mimetype'
])){
$arguments
[]
=
dirname
(
$data
[
'mimetype'
]);
$queryParts
[]
=
'mimepart=?'
;
}
$arguments
[]
=
$id
;
$query
=
OC_DB
::
prepare
(
'UPDATE *PREFIX*fscache SET '
.
implode
(
' , '
,
$queryParts
)
.
' WHERE id=?'
);
$query
->
execute
(
$arguments
);
}
/**
...
...
@@ -137,11 +156,13 @@ class OC_FileCache{
* - mtime
* - ctime
* - mimetype
* - encrypted
* - versioned
*/
public
static
function
getFolderContent
(
$path
){
$path
=
OC_Filesystem
::
getRoot
()
.
$path
;
$parent
=
self
::
getFileId
(
$path
);
$query
=
OC_DB
::
prepare
(
'SELECT name,ctime,mtime,mimetype,size FROM *PREFIX*fscache WHERE parent=?'
);
$query
=
OC_DB
::
prepare
(
'SELECT name,ctime,mtime,mimetype,size
,encrypted,versioned
FROM *PREFIX*fscache WHERE parent=?'
);
$result
=
$query
->
execute
(
array
(
$parent
))
->
fetchAll
();
if
(
is_array
(
$result
)){
return
$result
;
...
...
@@ -201,8 +222,9 @@ class OC_FileCache{
if
(
$mimetype
==
'httpd/unix-directory'
){
$size
=
0
;
}
else
{
if
((
$id
=
self
::
getFileId
(
$fullPath
))
!=-
1
){
$oldInfo
=
self
::
get
(
$fullPath
);
$id
=
self
::
getFileId
(
$fullPath
);
if
(
$id
!=-
1
){
$oldInfo
=
self
::
get
(
$path
);
$oldSize
=
$oldInfo
[
'size'
];
}
else
{
$oldSize
=
0
;
...
...
@@ -221,7 +243,6 @@ class OC_FileCache{
public
static
function
fileSystemWatcherDelete
(
$params
){
$path
=
$params
[
'path'
];
$fullPath
=
OC_Filesystem
::
getRoot
()
.
$path
;
error_log
(
"delete
$path
"
);
if
(
self
::
getFileId
(
$fullPath
)
==-
1
){
return
;
}
...
...
@@ -258,7 +279,6 @@ class OC_FileCache{
private
static
function
increaseSize
(
$path
,
$sizeDiff
){
while
((
$id
=
self
::
getFileId
(
$path
))
!=-
1
){
$query
=
OC_DB
::
prepare
(
'UPDATE *PREFIX*fscache SET size=size+? WHERE id=?'
);
error_log
(
'diff '
.
$path
.
' '
.
$sizeDiff
);
$query
->
execute
(
array
(
$sizeDiff
,
$id
));
$path
=
dirname
(
$path
);
}
...
...
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