-dirmove ($tempdir, "$out_dir")
- or die "Could not move $tempdir to $out_dir: $!";
+if (! dirmove ("$tempdir/out", "$out_dir")) {
+ warn "Could not move $tempdir/out to $out_dir: $!";
+ warn "Rollback";
+ remove_tree($out_dir);
+ dirmove ($out_dir . ".bak", $out_dir);
+} else {
+ remove_tree($out_dir . ".bak");
+}