aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/ak-fs-add11
-rwxr-xr-xbin/ak-fs-get16
2 files changed, 16 insertions, 11 deletions
diff --git a/bin/ak-fs-add b/bin/ak-fs-add
index 34ee3c0..0011faf 100755
--- a/bin/ak-fs-add
+++ b/bin/ak-fs-add
@@ -183,14 +183,17 @@ do
sed -n "$a"p "$workingIndex" | awk '{ print $1 }' >> level.$c.pair.$a-$b
sed -n "$b"p "$workingIndex" | awk '{ print $1 }' >> level.$c.pair.$a-$b
shaSum="$(sha512sum level.$c.pair.$a-$b | awk '{ print $1 }')"
- cp level.$c.pair.$a-$b $MERKLEDIR/$shaSum
+ mkdir -p $MERKLEDIR/$(_ak_return_hash_dir $shaSum)
+ cp level.$c.pair.$a-$b $MERKLEDIR/$(_ak_return_hash_path $shaSum)
sha512sum level.$c.pair.$a-$b | awk '{ print $1 }' >> level.$c.map
a=`expr "$a" + 2`
done
workingIndex="level.$c.map"
appendLastIfNotEven "$workingIndex"
shaSum=`sha512sum $workingIndex | awk '{ print $1 }'`
- cp $workingIndex $MERKLEDIR/$shaSum
+ mkdir -p $MERKLEDIR/$(_ak_return_hash_dir $shaSum)
+ cp $workingIndex $MERKLEDIR/$(_ak_return_hash_path $shaSum)
+# cp $workingIndex $MERKLEDIR/$shaSum
totalChunks=`cat $workingIndex | wc -l`
c=`expr $c - 1`
done
@@ -211,7 +214,7 @@ rm $TEMPORARYDIR/map2
counter=0
while IFS="" read -r p || [ -n "$p" ]
do
- printf "mv %s %s%s\n" "$(echo $p | awk '{ print $2 }')" "$CHKDIR" "$(echo $p | awk '{ print $1 }')" >> $TEMPORARYDIR/cmd_queue.sh
+ printf "mv %s %s/%s\n" "$(echo $p | awk '{ print $2 }')" "$CHKDIR" "$(echo $p | awk '{ print $1 }')" >> $TEMPORARYDIR/cmd_queue.sh
counter=`expr "$counter" + 1`
done < $TEMPORARYDIR/map
@@ -228,7 +231,7 @@ echo "$CHECKSUM $(basename "$FILE")" >> $TEMPORARYDIR/map
MAPFILEHASH="$(sha512sum $TEMPORARYDIR/map | awk '{ print $1 }')"
# and we rename it with it and move it to FILEMAPSDIR
-`sha512sum $TEMPORARYDIR/map | awk '{print "mv " $2 " '$FILEMAPSDIR'" $1}'`
+`sha512sum $TEMPORARYDIR/map | awk '{print "mv " $2 " '$FILEMAPSDIR/'" $1}'`
# We remove the TEMPORARYDIR
rm -rf $TEMPORARYDIR
diff --git a/bin/ak-fs-get b/bin/ak-fs-get
index 556f499..ea56caa 100755
--- a/bin/ak-fs-get
+++ b/bin/ak-fs-get
@@ -39,12 +39,13 @@ cd $TEMPASSIN
findDepth(){
currentNode="$1"
- if [ -f $fmrk/$currentNode ] && [ "$(du -b $fmrk/$currentNode | awk '{print $1}')" == "258" ]
+ pathToNode="$fmrk/$(ak-sm-hash-to-path --path $currentNode)"
+ if [ -f $pathToNode ] && [ "$(du -b $pathToNode | awk '{print $1}')" == "258" ]
then
- fileHead="$(head -n 1 $fmrk/$currentNode)"
+ fileHead="$(head -n 1 $pathToNode)"
counter="$(expr $counter + 1)"
findDepth "$fileHead"
- elif [ ! -f $fmrk/$currentNode ]
+ elif [ ! -f $pathToNode ]
then
printf "%s" "$counter" > depth
else
@@ -83,13 +84,14 @@ do
then
echo hi
else
- if [ -f $fmrk/$p ]
+ expectedPath="$fmrk/$(ak-sm-hash-to-path --path $p)"
+ if [ -f $expectedPath ]
then
- if [ "$(head -n 1 $fmrk/$p)" == "$(tail -n 1 $fmrk/$p)" ]
+ if [ "$(head -n 1 $expectedPath)" == "$(tail -n 1 $expectedPath)" ]
then
- head -n 1 $fmrk/$p >> workspace.$nextLevel
+ head -n 1 $expectedPath >> workspace.$nextLevel
else
- cat $fmrk/$p >> workspace.$nextLevel
+ cat $expectedPath >> workspace.$nextLevel
fi
elif [ -f $ftr/$p ]
then