Skip to content

Commit

Permalink
Acquire exclusive lock, we only want one migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Jan 11, 2016
1 parent a8c4ada commit 61c99e4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion framework/Cache/lib/Horde/Cache/Storage/File.php
Expand Up @@ -255,7 +255,13 @@ protected function _gc()

if (!empty($this->_params['sub']) &&
file_exists($this->_params['dir'] . '/' . self::GC_FILE)) {
$this->_migrateGc();
// If we cannot migrate, we cannot GC either, because we expect the
// new format.
try {
$this->_migrateGc();
} catch (Horde_Cache_Exception $e) {
return;
}
}

foreach ($this->_getGCFiles() as $filename) {
Expand Down Expand Up @@ -297,6 +303,9 @@ protected function _migrateGc()

$fhs = array();
$fp = fopen($filename, 'r');
if (!flock($fp, LOCK_EX)) {
throw new Horde_Cache_Exception('Cannot acquire lock for old garbage collection index');
}

// Loops through all cached files from the old index and write their GC
// information to the new GC indexes.
Expand Down

0 comments on commit 61c99e4

Please sign in to comment.