1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 04:20:55 +01:00

Fix an issue where we would try to release an unheld lock

Summary: Fixes T7484. If the lock failed, we'd still try to unlock it, which is incorrect.

Test Plan: Ran two `bin/repository update X` in different windows, got proper LockException instead of indirect symptomatic "not locked by this process" exception.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7484

Differential Revision: https://secure.phabricator.com/D12253
This commit is contained in:
epriestley 2015-04-01 17:37:46 -07:00
parent 898ccd7552
commit e9886c4353

View file

@ -58,7 +58,7 @@ final class PhabricatorRepositoryManagementUpdateWorkflow
$lock = PhabricatorGlobalLock::newLock($lock_name);
$lock->lock();
try {
$no_discovery = $args->getArg('no-discovery');
id(new PhabricatorRepositoryPullEngine())
@ -72,8 +72,8 @@ final class PhabricatorRepositoryManagementUpdateWorkflow
}
// TODO: It would be nice to discover only if we pulled something, but
// this isn't totally trivial. It's slightly more complicated with hosted
// repositories, too.
// this isn't totally trivial. It's slightly more complicated with
// hosted repositories, too.
$repository->writeStatusMessage(
PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE,
@ -90,6 +90,10 @@ final class PhabricatorRepositoryManagementUpdateWorkflow
$repository->writeStatusMessage(
PhabricatorRepositoryStatusMessage::TYPE_FETCH,
PhabricatorRepositoryStatusMessage::CODE_OKAY);
} catch (Exception $ex) {
$lock->unlock();
throw $ex;
}
} catch (Exception $ex) {
$repository->writeStatusMessage(
PhabricatorRepositoryStatusMessage::TYPE_FETCH,
@ -98,8 +102,6 @@ final class PhabricatorRepositoryManagementUpdateWorkflow
'message' => pht(
'Error updating working copy: %s', $ex->getMessage()),
));
$lock->unlock();
throw $ex;
}