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
7f1ff3e9
Commit
7f1ff3e9
authored
12 years ago
by
Frank Karlitschek
Browse files
Options
Downloads
Plain Diff
Merge pull request #2204 from owncloud/chache_updater_rename
Cache: better rename hook for cache updater
parents
86f6938c
1d3beffa
Branches
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/updater.php
+33
-10
33 additions, 10 deletions
lib/files/cache/updater.php
tests/lib/files/cache/updater.php
+3
-2
3 additions, 2 deletions
tests/lib/files/cache/updater.php
with
36 additions
and
12 deletions
lib/files/cache/updater.php
+
33
−
10
View file @
7f1ff3e9
...
...
@@ -53,12 +53,36 @@ class Updater {
}
}
static
public
function
renameUpdate
(
$from
,
$to
)
{
/**
* @var \OC\Files\Storage\Storage $storageFrom
* @var \OC\Files\Storage\Storage $storageTo
* @var string $internalFrom
* @var string $internalTo
*/
list
(
$storageFrom
,
$internalFrom
)
=
self
::
resolvePath
(
$from
);
list
(
$storageTo
,
$internalTo
)
=
self
::
resolvePath
(
$to
);
if
(
$storageFrom
&&
$storageTo
)
{
if
(
$storageFrom
===
$storageTo
)
{
$cache
=
$storageFrom
->
getCache
(
$internalFrom
);
$cache
->
move
(
$internalFrom
,
$internalTo
);
$cache
->
correctFolderSize
(
$internalFrom
);
$cache
->
correctFolderSize
(
$internalTo
);
self
::
correctFolder
(
$from
,
time
());
self
::
correctFolder
(
$to
,
time
());
}
else
{
self
::
deleteUpdate
(
$from
);
self
::
writeUpdate
(
$to
);
}
}
}
/**
* Update the mtime and ETag of all parent folders
*
* @param string $path
* @param string $time
*/
* Update the mtime and ETag of all parent folders
*
* @param string $path
* @param string $time
*/
static
public
function
correctFolder
(
$path
,
$time
)
{
if
(
$path
!==
''
&&
$path
!==
'/'
)
{
$parent
=
dirname
(
$path
);
...
...
@@ -66,9 +90,9 @@ class Updater {
$parent
=
''
;
}
/**
* @var \OC\Files\Storage\Storage $storage
* @var string $internalPath
*/
* @var \OC\Files\Storage\Storage $storage
* @var string $internalPath
*/
list
(
$storage
,
$internalPath
)
=
self
::
resolvePath
(
$parent
);
if
(
$storage
)
{
$cache
=
$storage
->
getCache
();
...
...
@@ -92,8 +116,7 @@ class Updater {
* @param array $params
*/
static
public
function
renameHook
(
$params
)
{
self
::
deleteUpdate
(
$params
[
'oldpath'
]);
self
::
writeUpdate
(
$params
[
'newpath'
]);
self
::
renameUpdate
(
$params
[
'oldpath'
],
$params
[
'newpath'
]);
}
/**
...
...
This diff is collapsed.
Click to expand it.
tests/lib/files/cache/updater.php
+
3
−
2
View file @
7f1ff3e9
...
...
@@ -54,6 +54,8 @@ class Updater extends \PHPUnit_Framework_TestCase {
Filesystem
::
clearMounts
();
Filesystem
::
mount
(
$this
->
storage
,
array
(),
'/'
.
self
::
$user
.
'/files'
);
\OC_Hook
::
clear
(
'OC_Filesystem'
);
\OC_Hook
::
connect
(
'OC_Filesystem'
,
'post_write'
,
'\OC\Files\Cache\Updater'
,
'writeHook'
);
\OC_Hook
::
connect
(
'OC_Filesystem'
,
'post_delete'
,
'\OC\Files\Cache\Updater'
,
'deleteHook'
);
\OC_Hook
::
connect
(
'OC_Filesystem'
,
'post_rename'
,
'\OC\Files\Cache\Updater'
,
'renameHook'
);
...
...
@@ -137,11 +139,10 @@ class Updater extends \PHPUnit_Framework_TestCase {
$this
->
assertFalse
(
$this
->
cache
->
inCache
(
'foo.txt'
));
$this
->
assertTrue
(
$this
->
cache
->
inCache
(
'bar.txt'
));
$cachedData
=
$this
->
cache
->
get
(
'bar.txt'
);
$this
->
assert
Not
Equals
(
$fooCachedData
[
'
etag
'
],
$cachedData
[
'
etag
'
]);
$this
->
assertEquals
(
$fooCachedData
[
'
fileid
'
],
$cachedData
[
'
fileid
'
]);
$mtime
=
$cachedData
[
'mtime'
];
$cachedData
=
$this
->
cache
->
get
(
''
);
$this
->
assertEquals
(
3
*
$textSize
+
$imageSize
,
$cachedData
[
'size'
]);
$this
->
assertNotEquals
(
$rootCachedData
[
'etag'
],
$cachedData
[
'etag'
]);
$this
->
assertEquals
(
$mtime
,
$cachedData
[
'mtime'
]);
}
}
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