Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make this work with php5.4
  • Loading branch information
tomneedham authored and Vincent Petry committed Nov 7, 2017
commit ef74cee82542a0b82e2fb7e86616b67fb3d73be3
12 changes: 10 additions & 2 deletions apps/files/command/scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ protected function scanFiles($user, $path, $verbose, OutputInterface $output, $s
$output->writeln("\t<error>Storage \"" . $storage->getCache()->getNumericStorageId() . '" cannot be repaired as it is currently in use, please try again later</error>');
return;
}
$stored = false;
try {
$repairStep = new RepairMismatchFileCachePath(
$connection,
Expand All @@ -154,8 +155,15 @@ protected function scanFiles($user, $path, $verbose, OutputInterface $output, $s
$repairStep->setStorageNumericId($storage->getCache()->getNumericStorageId());
$repairStep->setCountOnly(false);
$repairStep->run();
} finally {
$storage->releaseLock('', ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider);
} catch (\Exception $e) {
$stored = $e;
}

// Release the lock first
$storage->releaseLock('', ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider);
// Now throw the exception for handling elsewhere
if($stored) {
throw $stored;
}
});
}
Expand Down
7 changes: 2 additions & 5 deletions tests/lib/repair/repairmismatchfilecachepathtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@

namespace Test\Repair;


use OC\Repair\RepairMismatchFileCachePath;
use \OC\RepairStep;
use \OCP\IDBConnection;
use Test\TestCase;
use OCP\Files\IMimeTypeLoader;

/**
* Tests for repairing mismatch file cache paths
Expand All @@ -24,7 +21,7 @@
*/
class RepairMismatchFileCachePathTest extends TestCase {

/** @var RepairStep */
/** @var RepairMismatchFileCachePath */
private $repair;

/** @var IDBConnection */
Expand All @@ -35,7 +32,7 @@ protected function setUp() {

$this->connection = \OC::$server->getDatabaseConnection();

$mimeLoader = $this->getMockBuilder(IMimeTypeLoader::class)->getMock();
$mimeLoader = $this->getMockBuilder('OCP\Files\IMimeTypeLoader')->getMock();
$mimeLoader->method('getId')
->will($this->returnValueMap([
['httpd', 1],
Expand Down