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
aab33b8b
Commit
aab33b8b
authored
10 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
Remove deleted versions from the cache
parent
480f5ddd
Branches
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_versions/lib/versions.php
+21
-4
21 additions, 4 deletions
apps/files_versions/lib/versions.php
with
21 additions
and
4 deletions
apps/files_versions/lib/versions.php
+
21
−
4
View file @
aab33b8b
...
...
@@ -131,6 +131,23 @@ class Storage {
'filename'
=>
$filename
);
}
/**
* delete the version from the storage and cache
*
* @param \OC\Files\View $view
* @param string $path
*/
protected
static
function
deleteVersion
(
$view
,
$path
)
{
$view
->
unlink
(
$path
);
/**
* @var \OC\Files\Storage\Storage $storage
* @var string $internalPath
*/
list
(
$storage
,
$internalPath
)
=
$view
->
resolvePath
(
$path
);
$cache
=
$storage
->
getCache
(
$internalPath
);
$cache
->
remove
(
$internalPath
);
}
/**
* Delete versions of a file
*/
...
...
@@ -148,7 +165,7 @@ class Storage {
if
(
!
empty
(
$versions
))
{
foreach
(
$versions
as
$v
)
{
\OC_Hook
::
emit
(
'\OCP\Versions'
,
'preDelete'
,
array
(
'path'
=>
$path
.
$v
[
'version'
]));
$view
->
unlink
(
$filename
.
'.v'
.
$v
[
'version'
]);
self
::
deleteVersion
(
$view
,
$filename
.
'.v'
.
$v
[
'version'
]);
\OC_Hook
::
emit
(
'\OCP\Versions'
,
'delete'
,
array
(
'path'
=>
$path
.
$v
[
'version'
]));
}
}
...
...
@@ -219,7 +236,7 @@ class Storage {
return
true
;
}
else
if
(
$versionCreated
)
{
$users_view
->
unlink
(
$version
);
self
::
deleteVersion
(
$users_view
,
$version
);
}
}
return
false
;
...
...
@@ -471,7 +488,7 @@ class Storage {
foreach
(
$toDelete
as
$key
=>
$path
)
{
\OC_Hook
::
emit
(
'\OCP\Versions'
,
'preDelete'
,
array
(
'path'
=>
$path
));
$versionsFileview
->
unlink
(
$path
);
self
::
deleteVersion
(
$versionsFileview
,
$path
);
\OC_Hook
::
emit
(
'\OCP\Versions'
,
'delete'
,
array
(
'path'
=>
$path
));
unset
(
$allVersions
[
$key
]);
// update array with the versions we keep
\OCP\Util
::
writeLog
(
'files_versions'
,
"Expire: "
.
$path
,
\OCP\Util
::
DEBUG
);
...
...
@@ -485,7 +502,7 @@ class Storage {
while
(
$availableSpace
<
0
&&
$i
<
$numOfVersions
)
{
$version
=
current
(
$allVersions
);
\OC_Hook
::
emit
(
'\OCP\Versions'
,
'preDelete'
,
array
(
'path'
=>
$version
[
'path'
]
.
'.v'
.
$version
[
'version'
]));
$versionsFileview
->
unlink
(
$version
[
'path'
]
.
'.v'
.
$version
[
'version'
]);
self
::
deleteVersion
(
$versionsFileview
,
$version
[
'path'
]
.
'.v'
.
$version
[
'version'
]);
\OC_Hook
::
emit
(
'\OCP\Versions'
,
'delete'
,
array
(
'path'
=>
$version
[
'path'
]
.
'.v'
.
$version
[
'version'
]));
\OCP\Util
::
writeLog
(
'files_versions'
,
'running out of space! Delete oldest version: '
.
$version
[
'path'
]
.
'.v'
.
$version
[
'version'
]
,
\OCP\Util
::
DEBUG
);
$versionsSize
-=
$version
[
'size'
];
...
...
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