projects
/
grml.org.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
84dab36
)
Improve errorhandling
author
Alexander Wirt
<formorer@grml.org>
Fri, 6 Jan 2012 09:15:44 +0000
(10:15 +0100)
committer
Alexander Wirt
<formorer@grml.org>
Fri, 6 Jan 2012 09:15:44 +0000
(10:15 +0100)
gen_website
patch
|
blob
|
history
diff --git
a/gen_website
b/gen_website
index
1862584
..
0a92b8a
100755
(executable)
--- a/
gen_website
+++ b/
gen_website
@@
-5,12
+5,12
@@
use warnings;
use Template;
use File::Find::Rule;
use Template;
use File::Find::Rule;
-use File::Path qw(make_path);
+use File::Path qw(make_path
remove_tree
);
use File::Basename qw (fileparse dirname);
use File::Copy::Recursive qw(fcopy dirmove);
use File::Temp qw (tempdir);
use File::Basename qw (fileparse dirname);
use File::Copy::Recursive qw(fcopy dirmove);
use File::Temp qw (tempdir);
-my $out_dir = "out/";
+my $out_dir =
shift ||
"out/";
#find all files
#find all files
@@
-28,7
+28,7
@@
my @files = File::Find::Rule->or( $git, $file_rule )
->in('.');
#create a tempdir
->in('.');
#create a tempdir
-my $tempdir = tempdir( CLEANUP =>
0
);
+my $tempdir = tempdir( CLEANUP =>
1
);
#initialize template toolkit
#initialize template toolkit
@@
-55,8
+55,14
@@
foreach my $file (@files) {
$out_dir =~ s/\/$//;
if (-d $out_dir) {
$out_dir =~ s/\/$//;
if (-d $out_dir) {
-
mv ($out_dir, dirname($out_dir)
. ".bak")
+
dirmove ($out_dir, $out_dir
. ".bak")
or die "Could not move $out_dir to $out_dir.bak: $!";
}
or die "Could not move $out_dir to $out_dir.bak: $!";
}
-dirmove ($tempdir, "$out_dir")
- or die "Could not move $tempdir to $out_dir: $!";
+if (! dirmove ($tempdir, "$out_dir")) {
+ warn "Could not move $tempdir to $out_dir: $!";
+ warn "Rollback";
+ remove_tree($out_dir);
+ dirmove ($out_dir . ".bak", $out_dir);
+} else {
+ remove_tree($out_dir . ".bak");
+}