Skip to content

Commit 83779e5

Browse files
committed
import_binary_sample.php: skip mode tuning
Add --includeSpecial and until it's set, always add skip mode "special".
1 parent 147b3a6 commit 83779e5

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818
},
1919
"require": {
20-
"acdh-oeaw/arche-lib-ingest": "^5",
20+
"acdh-oeaw/arche-lib-ingest": "^5.1",
2121
"zozlak/argparse": "^1"
2222
},
2323
"require-dev": {

import_binary_sample.php

+17-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
// SKIP_NONE import all files
2020
// SKIP_BINARY_EXIST skip files which have corresponding repository resource with not empty binary payload. Use it if your upload failed in the middle but you used autocommit and some resources were ingested. In such a case the ingestion will skip resources which were already ingested and ingest only the ones which are still missing (saving your time and increases chances additional resources will be ingested).
2121
// SKIP_EXIST skip files which have corresponding repository resource. Like SKIP_BINARY_EXIST but it's enough if a resource exists (it doesn't have to have a binary payload).
22-
$skip = ['SKIP_NOT_EXIST', 'SKIP_BINARY_EXIST'];
22+
// SKIP_SPECIAL skip files with a name starting with a dot and Thumbs.db
23+
$skip = ['SKIP_NOT_EXIST', 'SKIP_BINARY_EXIST', 'SKIP_SPECIAL'];
2324
$assignDefaultClass = false; // Should collections/binary resources be assigned a default class (e.g. acdh:Collection and acdh:Resource). In case of ingesting binary data for already existing repository resources it might be safer to choose "false" (preserve their existing classes)
2425
$parentResourceId = ''; // Parent resource ID - typically the top-level collection ID (e.g. 'https://id.acdh.oeaw.ac.at/wollmilchsau'). ParentResourceId may be empty. In such a case files in the indexed directory root won't be attached to any parent by the Indexer (but they can still have parents defined e.g. trough a metadata import).
2526
$versioning = 'VERSIONING_NONE'; // VERSIONING_NONE, VERSIONING_ALWAYS, VERSIONING_DIGEST, VERSIONING_DATE
@@ -52,14 +53,15 @@
5253
$rc = new ReflectionClass(Indexer::class);
5354

5455
if (count($argv) > 1) {
55-
$errModes = ['fail', 'pass', 'continue'];
56-
$skipModes = ['none', 'not_exist', 'exist', 'binary_exist'];
57-
$versioningModes = ['none', 'always', 'digest', 'date'];
58-
$filterTypes = ['match', 'skip'];
59-
$parser = new ArgumentParser();
56+
$errModes = ['fail', 'pass', 'continue'];
57+
$skipModes = ['none', 'not_exist', 'exist', 'binary_exist'];
58+
$versioningModes = ['none', 'always', 'digest', 'date'];
59+
$filterTypes = ['match', 'skip'];
60+
$skipDefault = ['none'];
61+
$parser = new ArgumentParser();
6062
$parser->addArgument('--parentId');
61-
$parser->addArgument('--skip', choices: $skipModes, nargs: ArgumentParser::NARGS_STAR, default: [
62-
'none'], help: '(default %(default)s)');
63+
$parser->addArgument('--skip', choices: $skipModes, nargs: ArgumentParser::NARGS_STAR, default: $skipDefault, help: '(default %(default)s)');
64+
$parser->addArgument('--includeSpecial', action: ArgumentParser::ACTION_STORE_TRUE, default: false, help: 'if not set, the skip mode "special" is always enabled');
6365
$parser->addArgument('--versioning', choices: $versioningModes, default: 'none', help: '(default %(default)s)');
6466
$parser->addArgument('--sizeLimit', type: ArgumentParser::TYPE_INT, default: -1, help: 'Maximum uploaded file size in bytes. -1 means no limit. (default %(default)s)', metavar: 'BYTES');
6567
$parser->addArgument('--filenameFilter');
@@ -78,9 +80,12 @@
7880
$parser->addArgument('repoUrl');
7981
$parser->addArgument('user');
8082
$parser->addArgument('password');
81-
$args = $parser->parseArgs(array_slice($argv, 1));
82-
$parentResourceId = $args->parentId;
83-
$skip = array_map(fn($x) => 'SKIP_' . mb_strtoupper($x), $args->skip);
83+
$args = $parser->parseArgs(array_slice($argv, 1));
84+
$parentResourceId = $args->parentId;
85+
$skip = array_map(fn($x) => 'SKIP_' . mb_strtoupper($x), $args->skip);
86+
if (!$args->includeSpecial) {
87+
$skip[] = 'SKIP_SPECIAL';
88+
}
8489
$versioning = 'VERSIONING_' . mb_strtoupper($args->versioning);
8590
$sizeLimit = $args->sizeLimit;
8691
$filenameFilter = '`' . $args->filenameFilter . '`';
@@ -107,7 +112,7 @@
107112
$errMode = $rc->getConstant($errMode);
108113
$skip = is_array($skip) ? $skip : [$skip];
109114
$skip = array_map(fn($x) => $rc->getConstant($x), $skip);
110-
$skip = array_sum($skip);
115+
$skip = array_sum(array_unique($skip));
111116
$versioning = $rc->getConstant($versioning);
112117
$filterType = $rc->getConstant($filterType);
113118

0 commit comments

Comments
 (0)