diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2023-08-19 14:47:30 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2023-08-19 14:47:30 +0300 |
commit | 3855b9b657568f2270d63eae157923cc119fa866 (patch) | |
tree | 6eb46ebd37836f3820c8c6f73ca216d544704913 /bin | |
parent | 47f0fb1bae66ce55be238578a24b0168076b7f12 (diff) | |
download | arching-kaos-tools-3855b9b657568f2270d63eae157923cc119fa866.tar.gz arching-kaos-tools-3855b9b657568f2270d63eae157923cc119fa866.tar.bz2 arching-kaos-tools-3855b9b657568f2270d63eae157923cc119fa866.zip |
Fixed bug for files less than 4097 bytes
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/ak-sm-merkle-tree | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/bin/ak-sm-merkle-tree b/bin/ak-sm-merkle-tree index 60ad1ef..2ff6493 100755 --- a/bin/ak-sm-merkle-tree +++ b/bin/ak-sm-merkle-tree @@ -122,9 +122,14 @@ fi # We get the SHA512 hash for the $FILE given CHECKSUM=$(sha512sum "$FILE"|awk '{print $1}') - -# We split the file into 4*1024 bytes and output the chunks into TECHDIR -split -a 50 -b 4096 --additional-suffix ".chk" -d "$FILE" "$TECHDIR$(basename "$FILE")-" +FILE_SIZE="$(du -b $FILE | awk '{ print $1 }')" +if [ $FILE_SIZE -lt 4097 ] +then + cp $FILE "$TECHDIR$(basename "$FILE")-00000000000000000000000000000000000000000000000000.chk" +else + # We split the file into 4*1024 bytes and output the chunks into TECHDIR + split -a 50 -b 4096 --additional-suffix ".chk" -d "$FILE" "$TECHDIR$(basename "$FILE")-" +fi # We go over there... cd $TECHDIR @@ -172,9 +177,9 @@ do a=`expr "$a" + 2` done workingIndex="level.$c.map" + appendLastIfNotEven "$workingIndex" shaSum=`sha512sum $workingIndex | awk '{ print $1 }'` cp $workingIndex $MERKLEDIR/$shaSum - appendLastIfNotEven "$workingIndex" totalChunks=`cat $workingIndex | wc -l` c=`expr $c - 1` done |