Fixed treatment of temporary files
Change-Id: I2c5bce3c916dfc7b35c9cca07963bd66c314430f
diff --git a/Changes b/Changes
index 3b0c5b8..140240b 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+0.20 2016-10-15
+ - Fixed treatment of temporary folders in script
+
0.19 2016-08-17
- Added test for direct I5 support.
- Fixed support for Mojolicious 7.
diff --git a/lib/KorAP/XML/Krill.pm b/lib/KorAP/XML/Krill.pm
index 2126648..ba99cec 100644
--- a/lib/KorAP/XML/Krill.pm
+++ b/lib/KorAP/XML/Krill.pm
@@ -15,7 +15,7 @@
use Data::Dumper;
use File::Spec::Functions qw/catdir catfile catpath splitdir splitpath rel2abs/;
-our $VERSION = '0.19';
+our $VERSION = '0.20';
has 'path';
has [qw/text_sigle doc_sigle corpus_sigle/];
diff --git a/script/korapxml2krill b/script/korapxml2krill
index b5e9ff6..6b7b9df 100644
--- a/script/korapxml2krill
+++ b/script/korapxml2krill
@@ -63,9 +63,13 @@
#
# 2016/07/06
# - Added MDParser#Dependency
+#
+# 2016/10/15
+# - Fixed temporary path issue in script.
+#
# ----------------------------------------------------------
-our $LAST_CHANGE = '2016/08/16';
+our $LAST_CHANGE = '2016/10/15';
our $LOCAL = $FindBin::Bin;
our $VERSION_MSG = <<"VERSION";
Version $KorAP::XML::Krill::VERSION - diewald\@ids-mannheim.de - $LAST_CHANGE
@@ -370,7 +374,8 @@
print 'Convert ['. ($jobs > 0 ? "\$$pid:" : '') .
($iter++) . "/$count]" .
($code ? " $code" : '') .
- " $$data\n";
+ ' ' . $data->[0] . "\n";
+ $data->[1] = undef if $data->[1];
}
);
@@ -418,10 +423,10 @@
$pool->start and next DIRECTORY_LOOP;
if ($batch_file->process($dirs[$i] => $filename)) {
- $pool->finish(0, \("Processed " . $filename));
+ $pool->finish(0, ["Processed " . $filename]);
}
else {
- $pool->finish(1, \("Unable to process " . $dirs[$i]));
+ $pool->finish(1, ["Unable to process " . $dirs[$i]]);
};
};
}
@@ -442,9 +447,6 @@
my @dirs = $archive->list_texts;
$count = scalar @dirs;
- # Create temporary file
- $temp = File::Temp->newdir;
-
ARCHIVE_LOOP:
for (my $i = 0; $i < $count; $i++) {
@@ -462,6 +464,9 @@
# Get the next fork
$pool->start and next ARCHIVE_LOOP;
+ # Create temporary file
+ $temp = File::Temp->newdir;
+
# Extract from archive
if ($archive->extract($dirs[$i], $temp)) {
@@ -473,16 +478,18 @@
# Write file
if ($batch_file->process($dir => $filename)) {
- $pool->finish(0, \("Processed " . $filename));
+ # Delete temporary file
+ $pool->finish(0, ["Processed " . $filename, $temp]);
}
else {
- $pool->finish(1, \("Unable to process " . $dir));
+ # Delete temporary file
+ $pool->finish(1, ["Unable to process " . $dir, $temp]);
};
}
# Unable to extract
else {
- $pool->finish(1, \("Unable to extract " . $dirs[$i]));
+ $pool->finish(1, ["Unable to extract " . $dirs[$i], $temp]);
};
};
}
@@ -493,9 +500,6 @@
$pool->wait_all_children;
- # Delete temporary file
- $temp = undef;
-
# Delete cache file
unlink($cache_file) if $cache_delete;