Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zozlak committed Sep 25, 2024
1 parent c1d799f commit 04a246d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/acdhOeaw/arche/lib/ingest/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ public function import(string $errorMode = self::ERRMODE_FAIL,
continue;
}
// handle reingestion on "HTTP 409 Conflict"
$isConflict = $j instanceof Conflict && preg_match('/Resource [0-9]+ locked|Transaction [0-9]+ locked|Owned by other request|Lock not available|duplicate key value/', $j->getMessage());
$isConflict = $j instanceof Conflict && preg_match(MetadataCollection::ALLOWED_CONFLICT_REASONS_REGEX, $j->getMessage());
$isNetworkError = $j instanceof ConnectException;
if (($isConflict || $isNetworkError) && $chunk[$n]->getUploadsCount() <= $retries + 1) {
$filesToImport[] = $chunk[$n];
Expand Down
21 changes: 11 additions & 10 deletions src/acdhOeaw/arche/lib/ingest/MetadataCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@
*/
class MetadataCollection extends Dataset {

const SKIP = 1;
const CREATE = 2;
const ERRMODE_FAIL = 'fail';
const ERRMODE_PASS = 'pass';
const ERRMODE_INCLUDE = 'include';
const NETWORKERROR_SLEEP = 3;
const SKIP = 1;
const CREATE = 2;
const ERRMODE_FAIL = 'fail';
const ERRMODE_PASS = 'pass';
const ERRMODE_INCLUDE = 'include';
const NETWORKERROR_SLEEP = 3;
const ALLOWED_CONFLICT_REASONS_REGEX = '/Resource [0-9]+ locked|Transaction [0-9]+ locked|Owned by other request|Lock not available|duplicate key value|deadlock detected/';

/**
* Turns debug messages on.
Expand Down Expand Up @@ -312,7 +313,7 @@ function (RepoResource $repoRes) use ($meta, $progress) {
$sleep = false;
foreach ($chunkRepoRes as $n => $j) {
// handle reingestion on "HTTP 409 Conflict"
$conflict = $j instanceof Conflict && preg_match('/Resource [0-9]+ locked|Transaction [0-9]+ locked|Owned by other request|Lock not available|deadlock detected/', $j->getMessage());
$conflict = $j instanceof Conflict && preg_match(self::ALLOWED_CONFLICT_REASONS_REGEX, $j->getMessage());
$notFound = $j instanceof NotFound;
$networkError = $j instanceof ConnectException;
if ($conflict || $notFound || $networkError) {
Expand Down Expand Up @@ -376,9 +377,9 @@ private function filterResources(string $namespace, int $singleOutNmsp): array {
// or (at lest one) non-ID property
$validTmp = new SplObjectStorage();
foreach ($this->getIterator(new QT($nnTmpl)) as $quad) {
$sbj = $quad->getSubject();
$nonIdCond = !$idProp->equals($quad->getPredicate());
$nmspCond = $idProp && str_starts_with((string) $quad->getObject(), $namespace);
$sbj = $quad->getSubject();
$nonIdCond = !$idProp->equals($quad->getPredicate());
$nmspCond = $idProp && str_starts_with((string) $quad->getObject(), $namespace);
if ($nonIdCond || $nmspCond) {
$validTmp->attach($sbj);
}
Expand Down

0 comments on commit 04a246d

Please sign in to comment.