Improved 'already processed' message
Change-Id: I3e5ccf20335ac7b262b9a73ae7351c70ab92a972
diff --git a/Changes b/Changes
index 93a1244..10a51e2 100644
--- a/Changes
+++ b/Changes
@@ -1,7 +1,8 @@
-0.23 2016-10-28
+0.23 2016-10-31
- Added wildcard support for document extraction
- Fixed archive iteration to not duplicate the first archive
- Added parallel extraction for document sigles
+ - Improved return value for existing files
0.22 2016-10-26
- Added support for document extraction
diff --git a/lib/KorAP/XML/Batch/File.pm b/lib/KorAP/XML/Batch/File.pm
index 0f56b3c..dbb6ded 100644
--- a/lib/KorAP/XML/Batch/File.pm
+++ b/lib/KorAP/XML/Batch/File.pm
@@ -31,7 +31,7 @@
if (!$self->{overwrite} && $output && -e $output) {
$self->{log}->debug($output . ' already exists');
- return;
+ return -1;
};
# Create and parse new document
diff --git a/script/korapxml2krill b/script/korapxml2krill
index cedd84e..ecb50fb 100644
--- a/script/korapxml2krill
+++ b/script/korapxml2krill
@@ -468,8 +468,11 @@
# Get the next fork
$pool->start and next DIRECTORY_LOOP;
- if ($batch_file->process($dirs[$i] => $filename)) {
- $pool->finish(0, ["Processed " . $filename]);
+ if (my $return = $batch_file->process($dirs[$i] => $filename)) {
+ $pool->finish(
+ 0,
+ ["Processed " . $filename . ($return == -1 ? " - already existing" : '')]
+ );
}
else {
$pool->finish(1, ["Unable to process " . $dirs[$i]]);
@@ -526,9 +529,13 @@
my $dir = catdir($input, $doc, $text);
# Write file
- if ($batch_file->process($dir => $filename)) {
+ if (my $return = $batch_file->process($dir => $filename)) {
# Delete temporary file
- $pool->finish(0, ["Processed " . $filename, $temp]);
+ $pool->finish(
+ 0,
+ ["Processed " . $filename . ($return == -1 ? " - already existing" : ''), $temp]
+ );
+ #$pool->finish(0, ["Processed " . $filename, $temp]);
}
else {
# Delete temporary file
diff --git a/t/batch_file.t b/t/batch_file.t
index 50b59a8..ccfa62f 100644
--- a/t/batch_file.t
+++ b/t/batch_file.t
@@ -117,7 +117,7 @@
# Check overwriting
$bf->{overwrite} = 0;
-ok(!$bf->process($path => $output), 'Process file');
+is($bf->process($path => $output), -1, 'Process file');
done_testing;
__END__