Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rosettaExitStrategy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Digital Preservation
rosettaExitStrategy
Commits
55142eae
Commit
55142eae
authored
3 years ago
by
Andreas Romeyke
Browse files
Options
Downloads
Patches
Plain Diff
- added support for multiple search dirs
parent
63e18fa0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
perl/exit_strategy.pl
+83
-64
83 additions, 64 deletions
perl/exit_strategy.pl
with
83 additions
and
64 deletions
perl/exit_strategy.pl
+
83
−
64
View file @
55142eae
...
...
@@ -394,47 +394,55 @@ sub check_if_db_conform ($string, $filename) {
}
}
sub
searching_ie_files
($dir, $tmp_ies_unsorted_file) {
sub
searching_ie_files
($dir
s_ref
, $tmp_ies_unsorted_file) {
my
$cnt_unsorted_files
=
0
;
my
$first_two_levels_of_dirs
=
0
;
###
my
$wanted_twolevel_dircount
=
sub
{
my
$relpath
=
$
File::Find::
name
;
$relpath
=~
s{^\Q$dir\E/?}{}
;
my
$depth
=
File::
Spec
->
splitdir
(
$relpath
);
$depth
>=
2
and
$
File::Find::
prune
=
1
;
if
(
-
d
$_
)
{
$first_two_levels_of_dirs
++
;}
};
###
find
(
$wanted_twolevel_dircount
,
$dir
);
my
$progressbar
=
Time::
Progress
->
new
(
min
=>
0
,
max
=>
$first_two_levels_of_dirs
,
smoothing
=>
1
);
my
$dircount
=
0
;
###
my
$wanted_process_sip
=
sub
{
if
(
-
f
&&
m/V(\d+)-IE\d+\.xml$/
)
{
my
$version
=
$
1
;
my
$file
=
$
File::Find::
name
;
# fake name to ue alphabetical sort
my
$fakeversion
=
sprintf
("
%05i
",
$version
);
$file
=~
s/V(\d+)-IE/V$fakeversion-IE/
;
$tmp_ies_unsorted_file
->
append
(
$file
.
"
\n
");
$cnt_unsorted_files
++
;
$
File::Find::
prune
=
1
;
}
elsif
(
-
d
)
{
my
$pass
=
0
;
my
@dirs
=
@
{
$dirs_ref
};
my
$maxpass
=
scalar
@dirs
;
foreach
my
$dir
(
@dirs
)
{
$pass
++
;
my
$first_two_levels_of_dirs
=
0
;
###
my
$wanted_twolevel_dircount
=
sub
{
my
$relpath
=
$
File::Find::
name
;
$relpath
=~
s{^\Q$dir\E/?}{}
;
my
$depth
=
File::
Spec
->
splitdir
(
$relpath
);
if
(
$depth
<=
2
)
{
print
$progressbar
->
report
("
find IE files: %40b ETA: %E
\r
",
$dircount
++
);
$depth
>=
2
and
$
File::Find::
prune
=
1
;
if
(
-
d
$_
)
{
$first_two_levels_of_dirs
++
;}
};
###
find
(
$wanted_twolevel_dircount
,
$dir
);
my
$progressbar
=
Time::
Progress
->
new
(
min
=>
0
,
max
=>
$first_two_levels_of_dirs
,
smoothing
=>
1
);
my
$dircount
=
0
;
###
my
$wanted_process_sip
=
sub
{
if
(
-
f
&&
m/V(\d+)-IE\d+\.xml$/
)
{
my
$version
=
$
1
;
my
$file
=
$
File::Find::
name
;
# fake name to ue alphabetical sort
my
$fakeversion
=
sprintf
("
%05i
",
$version
);
$file
=~
s/V(\d+)-IE/V$fakeversion-IE/
;
$tmp_ies_unsorted_file
->
append
(
$file
.
"
\n
");
$cnt_unsorted_files
++
;
$
File::Find::
prune
=
1
;
}
}
return
;
};
###
find
(
$wanted_process_sip
,
$dir
);
say
"";
elsif
(
-
d
)
{
my
$relpath
=
$
File::Find::
name
;
$relpath
=~
s{^\Q$dir\E/?}{}
;
my
$depth
=
File::
Spec
->
splitdir
(
$relpath
);
if
(
$depth
<=
2
)
{
print
$progressbar
->
report
("
find IE files (pass
$pass
/
$maxpass
: %40b ETA: %E
\r
",
$dircount
++
);
}
}
return
;
};
###
find
(
$wanted_process_sip
,
$dir
);
say
"";
}
return
$cnt_unsorted_files
;
}
...
...
@@ -482,40 +490,51 @@ if ($#ARGV_tail < 0) {
die
"
you need a directory as argument
\n
";
}
my
$dir
=
shift
@ARGV_tail
;
if
(
defined
$dir
&&
-
d
"
$dir
")
{
say
"
preparing SQL
";
$tmp_ies_unsorted_file
->
touch
();
say
"
searching IE files
";
my
$cnt_unsorted_files
=
searching_ie_files
(
$dir
,
$tmp_ies_unsorted_file
);
# /permanent_storage/2020/04/02/IE201080/V1-FL201091.xml
# /permanent_storage/2020/04/02/IE201080/V2-FL201091.xml
my
$fh_unsorted_IEs
=
$tmp_ies_unsorted_file
->
openr
();
my
$count
=
0
;
my
$progressbar
=
Time::
Progress
->
new
(
min
=>
0
,
max
=>
$cnt_unsorted_files
,
smoothing
=>
1
);
say
"
preparing SQL
";
my
$dbh
=
DBI
->
connect
("
dbi:SQLite:dbname=
$db_filename
",
"",
"",
{
RaiseError
=>
1
,
sqlite_unicode
=>
1
,
})
or
die
"
could not connect to database (file '
$db_filename
')
",
$
DBI::
errstr
;
write_database_creation
(
$dbh
);
write_tables_creation
(
$dbh
);
write_prepare_insert
(
$dbh
);
write_index_creation
(
$dbh
);
$dbh
->
disconnect
or
warn
("
disconnecting problems,
",
$dbh
->
errstr
);
if
(
0
==
@ARGV_tail
){
die
"
no directory given on commandline
"
}
my
@dirs
;
while
(
@ARGV_tail
>
0
)
{
my
$dir
=
shift
@ARGV_tail
;
if
(
defined
$dir
&&
-
d
"
$dir
")
{
push
@dirs
,
$dir
;
}
}
$tmp_ies_unsorted_file
->
touch
();
say
"
searching IE files
";
my
$cnt_unsorted_files
=
searching_ie_files
(
\
@dirs
,
$tmp_ies_unsorted_file
);
# /permanent_storage/2020/04/02/IE201080/V1-FL201091.xml
# /permanent_storage/2020/04/02/IE201080/V2-FL201091.xml
my
$fh_unsorted_IEs
=
$tmp_ies_unsorted_file
->
openr
();
my
$count
=
0
;
my
$progressbar
=
Time::
Progress
->
new
(
min
=>
0
,
max
=>
$cnt_unsorted_files
,
smoothing
=>
1
);
while
(
<
$fh_unsorted_IEs
>
)
{
chomp
;
print
$progressbar
->
report
("
parse IE files: %40b ETA: %E
\r
",
$count
++
);
s/V0*(\d+-IE)/V$1/
;
# revert fake version
my
$ret
=
parse_iexml
(
$_
,
$flag_recovery
);
my
$dbh
=
DBI
->
connect
("
dbi:SQLite:dbname=
$db_filename
",
"",
"",
{
RaiseError
=>
1
,
sqlite_unicode
=>
1
,
})
or
die
"
could not connect to database (file '
$db_filename
')
",
$
DBI::
errstr
;
write_database_creation
(
$dbh
);
write_tables_creation
(
$dbh
);
write_prepare_insert
(
$dbh
);
write_index_creation
(
$dbh
);
while
(
<
$fh_unsorted_IEs
>
)
{
chomp
;
print
$progressbar
->
report
("
parse IE files: %40b ETA: %E
\r
",
$count
++
);
s/V0*(\d+-IE)/V$1/
;
# revert fake version
my
$ret
=
parse_iexml
(
$_
,
$flag_recovery
);
write_addsql
(
$dbh
,
$ret
);
}
say
"";
write_addsql
(
$dbh
,
$ret
);
$dbh
->
disconnect
or
warn
("
disconnecting problems,
",
$dbh
->
errstr
);
say
"
processed
$count
uniq IEs
";
}
else
{
die
"
no directory given on commandline
"
}
say
"";
say
"
processed
$count
uniq IEs
";
say
"";
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment