diff --git a/src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php b/src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php index 9f07ce491b..b59c4b859a 100644 --- a/src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php +++ b/src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php @@ -27,6 +27,7 @@ final class PhabricatorRepositoryPullLocalDaemon extends PhabricatorDaemon { + private $statusMessageCursor = 0; /* -( Pulling Repositories )----------------------------------------------- */ @@ -259,8 +260,25 @@ final class PhabricatorRepositoryPullLocalDaemon */ private function loadRepositoryUpdateMessages() { $type_need_update = PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE; - return id(new PhabricatorRepositoryStatusMessage()) - ->loadAllWhere('statusType = %s', $type_need_update); + $messages = id(new PhabricatorRepositoryStatusMessage())->loadAllWhere( + 'statusType = %s AND id > %d', + $type_need_update, + $this->statusMessageCursor); + + // Keep track of messages we've seen so that we don't load them again. + // If we reload messages, we can get stuck a loop if we have a failing + // repository: we update immediately in response to the message, but do + // not clear the message because the update does not succeed. We then + // immediately retry. Instead, messages are only permitted to trigger + // an immediate update once. + + foreach ($messages as $message) { + $this->statusMessageCursor = max( + $this->statusMessageCursor, + $message->getID()); + } + + return $messages; }