lumia

Archive checksum manager
git clone git://lumidify.org/lumia.git
Log | Files | Refs | README | LICENSE

commit 154589f88e7bac6026aae65e6806b00fbffdcee7
parent a75299d2d4c60eef97d0c97daf5efb1898642300
Author: lumidify <nobody@lumidify.org>
Date:   Sat,  2 Jan 2021 21:58:12 +0100

Make it work on implementations of cksum that don't have -q; fix documentation

Diffstat:
Mlumia.pl | 28++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/lumia.pl b/lumia.pl @@ -1,7 +1,7 @@ #!/usr/bin/env perl # TODO: some way to avoid writing .lumidify* in dirs but still index them? -# TODO: store modified date and checksum filed with changed date +# TODO: store modified date and checksum files with changed date # TODO: add option to just check dir structure or maybe check if everything exists # TODO: add option to compare cksums of two dirs # TODO: exit status! @@ -25,9 +25,9 @@ my $DOUBLE_CKSUM_FILE = ".lumidify_archive_cksums.cksum"; # uncomment this instead of the lines below to use # sha256 instead of cksum as the hash algorithm -#my $CKSUM_CMD = 'sha256 -q'; +#my $CKSUM_CMD = 'sha256'; #my $CKSUM_NUMFIELDS = 1; -my $CKSUM_CMD = 'cksum -q'; +my $CKSUM_CMD = 'cksum'; my $CKSUM_NUMFIELDS = 2; my %SPECIAL_FILES = ( @@ -210,7 +210,8 @@ sub get_cksum { return undef; } chomp $cksum_output; - return $cksum_output; + my @fields = split(/ /, $cksum_output, $CKSUM_NUMFIELDS+1); + return join(" ", @fields[0..$CKSUM_NUMFIELDS-1]); } # check the checksums in $dir/$cksum_file @@ -1020,8 +1021,10 @@ It does not matter if the options are written before or after the command. If C<--> is written anywhere on the command line, option parsing is stopped, so that files starting with a hyphen can still be specified. -Note that C<-q> and C<-f> are in no way opposites and are, in fact, never -supported on the same command. +Note that C<-q> and C<-v> aren't exactly opposites - C<-q> applies to commands +like B<check>, where it suppresses printing of the individual files, while +C<-v> applies to commands like B<cp>, where it is just passed on to the system +command called in the background. Note further that this is very inconsistent, like the rest of the program, but the author has made too many bad decisions to rectify that problem at the moment. @@ -1282,16 +1285,13 @@ faster than other algorithms. There is currently no convenient way to change the algorithm other than changing the $CKSUM_CMD and $CKSUM_NUMFIELDS variables at the top of -lumia.pl. $CKSUM_CMD must be the command that returns only the checksum +lumia.pl. $CKSUM_CMD must be the command that returns the checksum when it is given a file, and $CKSUM_NUMFIELDS specifies the number of space-separated fields the checksum consists of. This has to be specified -because cksum returns two numbers while sha256, for instance, only outputs -one long checksum. - -This could be improved a lot, especially since there really isn't any -reason why the file-reading function can't just take whatever comes before -the first opening quote as the checksum, making $CKSUM_NUMFIELDS redundant. -I'm too lazy to change that right now, though. +in order to determine where the checksum ends and the filename begins in +the output. This would be redundant if all implementations of cksum +supported '-q' for outputting only the checksum, but that only seems to +be supported by some implementations. =head1 USAGE SCENARIOS