Skip to content

Commit

Permalink
Start a fresh index for each directory while migrating (Bug #14258).
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Feb 16, 2016
1 parent 9d9b6c7 commit 395d10c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion framework/Cache/lib/Horde/Cache/Storage/File.php
Expand Up @@ -251,7 +251,6 @@ protected function _keyToFile($key, $create = false)
protected function _gc()
{
$c_time = time();
$excepts = array();

if (!empty($this->_params['sub']) &&
file_exists($this->_params['dir'] . '/' . self::GC_FILE)) {
Expand All @@ -265,6 +264,7 @@ protected function _gc()
}

foreach ($this->_getGCFiles() as $filename) {
$excepts = array();
if (is_readable($filename)) {
$fp = fopen($filename, 'r');
while (!feof($fp) && ($data = fgets($fp))) {
Expand Down
2 changes: 2 additions & 0 deletions framework/Cache/package.xml
Expand Up @@ -27,6 +27,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [jan] Fix incomplete migration from old to new garbage collection in file backend (Bug #14258).
* [jan] Mark PHP 7 as supported.
</notes>
<contents>
Expand Down Expand Up @@ -675,6 +676,7 @@ Initial packaging.
<date>2016-02-01</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [jan] Fix incomplete migration from old to new garbage collection in file backend (Bug #14258).
* [jan] Mark PHP 7 as supported.
</notes>
</release>
Expand Down
17 changes: 17 additions & 0 deletions framework/Cache/test/Horde/Cache/FileTest.php
Expand Up @@ -118,8 +118,25 @@ public function testMigrateGarbageCollection()
$storage->gc();

$this->assertFileExists($this->dir . '/7/horde_cache_gc');
$this->assertStringEqualsFile(
$this->dir . '/7/horde_cache_gc',
$this->dir . "/7/78f825aaa0103319aaa1a30bf4fe3ada \t"
. ($time + 100) . "\n"
);
$this->assertFileExists($this->dir . '/3/horde_cache_gc');
$this->assertStringEqualsFile(
$this->dir . '/3/horde_cache_gc',
$this->dir . "/3/3631578538a2d6ba5879b31a9a42f290\t"
. ($time + 100) . "\n"
);
$this->assertFileExists($this->dir . '/c/horde_cache_gc');
$this->assertStringEqualsFile(
$this->dir . '/c/horde_cache_gc',
$this->dir . "/c/c2add694bf942dc77b376592d9c862cd\t"
. ($time - 100) . "\n"
. $this->dir . "/c/caf8e34be07426ae7127c1b4829983c1\t"
. ($time - 100) . "\n"
);
$this->assertFileNotExists($this->dir . '/horde_cache_gc');
}

Expand Down

0 comments on commit 395d10c

Please sign in to comment.