Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/repository/daemon/commitdiscovery/base/PhabricatorRepositoryCommitDiscoveryDaemon.php b/src/applications/repository/daemon/commitdiscovery/base/PhabricatorRepositoryCommitDiscoveryDaemon.php
index 3b92f78a68..f538e2de2b 100644
--- a/src/applications/repository/daemon/commitdiscovery/base/PhabricatorRepositoryCommitDiscoveryDaemon.php
+++ b/src/applications/repository/daemon/commitdiscovery/base/PhabricatorRepositoryCommitDiscoveryDaemon.php
@@ -1,96 +1,97 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
abstract class PhabricatorRepositoryCommitDiscoveryDaemon
extends PhabricatorRepositoryDaemon {
private $repository;
private $commitCache = array();
final protected function getRepository() {
return $this->repository;
}
final public function run() {
$this->repository = $this->loadRepository();
$sleep = 15;
while (true) {
$found = $this->discoverCommits();
if ($found) {
$sleep = 15;
} else {
$sleep = min($sleep + 15, 60 * 15);
}
$this->sleep($sleep);
}
}
protected function isKnownCommit($target) {
if (isset($this->commitCache[$target])) {
return true;
}
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
'repositoryID = %s AND commitIdentifier = %s',
$this->getRepository()->getID(),
$target);
if (!$commit) {
return false;
}
$this->commitCache[$target] = true;
while (count($this->commitCache) > 16) {
array_shift($this->commitCache);
}
return true;
}
protected function recordCommit($commit_identifier, $epoch) {
$repository = $this->getRepository();
$commit = new PhabricatorRepositoryCommit();
$commit->setRepositoryID($repository->getID());
$commit->setCommitIdentifier($commit_identifier);
$commit->setEpoch($epoch);
try {
$commit->save();
$event = new PhabricatorTimelineEvent(
'cmit',
array(
'id' => $commit->getID(),
));
$event->recordEvent();
$this->commitCache[$commit_identifier] = true;
} catch (AphrontQueryDuplicateKeyException $ex) {
// Ignore. This can happen because we discover the same new commit
// more than once when looking at history, or because of races or
// data inconsistency or cosmic radiation; in any case, we're still
// in a good state if we ignore the failure.
+ $this->commitCache[$commit_identifier] = true;
}
$this->stillWorking();
}
abstract protected function discoverCommits();
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Dec 3, 3:16 PM (5 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
433660
Default Alt Text
(3 KB)

Event Timeline