commit 1299a04fa3eef185926a04ce7b434c56d504c515
parent aa3fbdeec22eabf826a6bf730f61d8df3d6f383e
Author: lumidify <nobody@lumidify.org>
Date:   Mon, 23 Mar 2020 17:24:54 +0100
Check for special files before copying, etc.
Diffstat:
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/lumia.pl b/lumia.pl
@@ -557,6 +557,10 @@ sub copy_files {
 			my $src_path = "$src_dir/$src_file";
 
 			my $dst_path = $diff_name ? $dst : "$dst_dir/$src_file";
+			if (exists $SPECIAL_FILES{$src_file} || exists $SPECIAL_FILES{basename $dst_path}) {
+				warn "ERROR: Not copying special file\n";
+				next;
+			}
 			next if prompt_overwrite($dst_path);
 			next if system("cp", "-av", $src_path, $dst);
 
@@ -584,6 +588,10 @@ sub copy_files {
 # automatically appends the basename of $src to $dst if $dst is a directory
 sub move_file {
 	my ($src, $dst) = @_;
+	if (exists $SPECIAL_FILES{basename $src} || exists $SPECIAL_FILES{basename $dst}) {
+		warn "ERROR: Not moving special file\n";
+		return 1;
+	}
 	if (-d $dst) {
 		$dst .= "/" . basename($src);
 	}
@@ -733,6 +741,10 @@ sub remove_from_same_dir {
 	my $dirs_touched = 0;
 	my $files_touched = 0;
 	foreach my $file (@files) {
+		if (exists $SPECIAL_FILES{$file}) {
+			warn "ERROR: not removing special file $file\n";
+			next;
+		}
 		my $fullpath = "$dir/$file";
 		if (!-e $fullpath) {
 			warn "\"$fullpath\": No such file or directory.\n";
diff --git a/test/.lumidify_archive_cksums b/test/.lumidify_archive_cksums
@@ -1,4 +1,4 @@
-2454254050 2 "fred2"
-2418082923 2 "bob1"
 2454254050 2 "bob3"
+2418082923 2 "bob1"
+2454254050 2 "fred2"
 4294967295 0 "bob2"
diff --git a/test/.lumidify_archive_cksums.cksum b/test/.lumidify_archive_cksums.cksum
@@ -1,2 +1,2 @@
-650526090 81 ".lumidify_archive_cksums"
+2943189886 81 ".lumidify_archive_cksums"
 3971863640 21 ".lumidify_archive_dirs"