From 5ad0e143e7f76c740defe6d983e4c54007a23b25 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Mon, 18 Mar 2024 03:26:43 +0200 Subject: Introduced dynamic splitting to keep chunks<250 --- bin/ak-fs-add | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/ak-fs-add b/bin/ak-fs-add index 37fe43b..b422d25 100755 --- a/bin/ak-fs-add +++ b/bin/ak-fs-add @@ -123,10 +123,17 @@ CHECKSUM=$(sha512sum "$FILE"|awk '{print $1}') FILE_SIZE="$(du -b $FILE | awk '{ print $1 }')" if [ $FILE_SIZE -lt 4097 ] then - cp $FILE "$TECHDIR$(basename "$FILE")-00000000000000000000000000000000000000000000000000.chk" + cp $FILE "$TECHDIR/$(basename "$FILE")-00000000000000000000000000000000000000000000000000.chk" else + FACTOR=1024 + while [ $(( $FILE_SIZE / $FACTOR )) -gt 250 ] + do + FACTOR=$(( $FACTOR * 2 )) + done + logit "INFO" "Gonna split in $FACTOR size" + sleep 30 # 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")-" + split -a 50 -b $FACTOR --additional-suffix ".chk" -d "$FILE" "$TECHDIR/$(basename "$FILE")-" fi # We go over there... -- cgit v1.2.3