diff options
Diffstat (limited to 'lib/_ak_fs')
| -rwxr-xr-x | lib/_ak_fs | 50 |
1 files changed, 48 insertions, 2 deletions
@@ -112,6 +112,14 @@ function _ak_fs_import(){ # _ak_log_info "Storing original hash of $1 along with its name" sha512sum "$1" > $TEMPDIR/3rd_gen_map + hashgrep="$(grep -rn $(cat $TEMPDIR/3rd_gen_map | cut -d ' ' -f 1) $AK_MAPSDIR)" + if [ $? -eq 0 ] + then + map="$(basename $( echo $hashgrep | cut -d ':' -f 1 ))" + _ak_log_error "File $1 found @ $map" + echo $map + exit 0 + fi _ak_log_info "Encoding to base64" base64 $1 > file FILE="file" @@ -346,6 +354,23 @@ function _ak_fs_list(){ fi } +function _ak_fs_long_list(){ + if [ -d "${AK_MAPSDIR}" ] + then + find $AK_MAPSDIR -type f | while read fina + do + stats="$(stat --format=%y ${fina}|tr -d '\n'|tr ' ' '_')" + date_stats="$(echo ${stats}|cut -d '_' -f 1)" + time_stats="$(echo ${stats}|cut -d '_' -f 2|cut -d '.' -f 1)" + cat $fina | tr '\n' ' ' | awk '{ print "'$(basename ${fina})' " "'$date_stats'" " " "'$time_stats'" " "$2 }' + done + else + _ak_log_debug "Making ${AK_MAPSDIR} directory" + mkdir -p ${AK_MAPSDIR} + _ak_log_debug "Empty directory" + fi +} + function _ak_fs_from_map_get_original_hash(){ if [ ! -z "$1" ] && [ -n "$1" ] then @@ -605,11 +630,16 @@ function _ak_fs_net_cat(){ counter="$(expr $counter + 1)" done base64 -d output > output.d + if [ $? -ne 0 ] + then + _ak_log_error "Fatal error during dencoding." + exit 1 + fi shaout="$(sha512sum output.d | awk '{print $1}')" expHash="$2" if [ "$shaout" == "$expHash" ] then - base64 -d output + cat output.d _ak_log_info "Recreation of $treeRootHash succeeded!" else _ak_log_error "Recreation of $treeRootHash failed!" @@ -630,6 +660,21 @@ function _ak_fs_net_get(){ echo "Look, I asked for a SHA512 hash, please try again" exit 1 fi + if [ -z $1 ] || [ ! -n "$1" ] + then + _ak_log_error "Empty 1" + exit 1 + fi + if [ -z $2 ] || [ ! -n "$2" ] + then + _ak_log_error "Empty 2" + exit 1 + fi + if [ -z $3 ] || [ ! -n "$3" ] + then + _ak_log_error "Empty 3" + exit 1 + fi _ak_fs_net_cat $1 $2 > $3 } @@ -702,6 +747,7 @@ function _ak_fs_from_map_net_get_original_filename(){ _ak_log_error "${reply} doesn't contain the appropriate info" exit 1 fi + cp ${reply} $AK_MAPSDIR/$1 cat ${reply} | head -n 1 | awk '{print $2}' break fi @@ -750,7 +796,7 @@ function _ak_fs_from_map_net_get_root_hash(){ function _ak_fs_net_get_from_map_hash(){ if _ak_fs_verify_input_is_hash "$1" then - _ak_fs_net_get `_ak_fs_from_map_net_get_root_hash $1` `_ak_fs_from_map_net_get_original_hash $1` `_ak_fs_from_map_get_original_filename $1` + _ak_fs_net_get `_ak_fs_from_map_net_get_root_hash $1` `_ak_fs_from_map_net_get_original_hash $1` `_ak_fs_from_map_net_get_original_filename $1` fi } |
