summaryrefslogtreecommitdiffstats
path: root/videomv.pl
diff options
context:
space:
mode:
Diffstat (limited to 'videomv.pl')
-rwxr-xr-xvideomv.pl9
1 files changed, 9 insertions, 0 deletions
diff --git a/videomv.pl b/videomv.pl
index a21bc33..004f51e 100755
--- a/videomv.pl
+++ b/videomv.pl
@@ -542,6 +542,11 @@ if (defined $old_symlink) {
&perform ("Deleting old symlink... ", unlink $old_symlink);
}
+open my $DIR, catdir($directors, $old_director) or die "Can't open: $!";
+if (scalar(grep( !/^\.\.?$/, readdir(DIR)) == 0)) {
+ &perform ("Removing empty dir... ", rmdir catdir($directors, $old_director));
+}
+closedir DIR or die "Can't close: $!";
&perform ("Creating new symlink... ",
symlink catfile(updir(),'DIRECTORS',$new_director,$new_filename),
@@ -635,6 +640,10 @@ sub revert {
$actions[0] = 'Deleting'. $1;
$rev = unlink $new_symlink;
}
+ elsif ($actions[0] =~ /^Removing( empty dir.*)/) {
+ $actions[0] = 'Creating'. $1;
+ $rev = mkdir catdir($directors, $old_director);
+ }
else {
print STDERR "Error: unknown action `" .$actions[0]. "'!\n";
$actions[0] = undef;