From 6accd4c39cc415e271c9c3bae8db7d376b9d5f4f Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Sun, 7 Aug 2022 13:11:44 +0300 Subject: [PATCH] Added archiving (7z) statuses --- utils/statuses2files.sh | 5 ++++- utils/statuses2files_group.sh | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/utils/statuses2files.sh b/utils/statuses2files.sh index 7aa2241..8cbdebd 100755 --- a/utils/statuses2files.sh +++ b/utils/statuses2files.sh @@ -12,7 +12,10 @@ for i in $ids; do if [ -f "$main_basedir"/all_statuses/$instance/$i/$i.json ]; then ids=$(echo "$ids" | sed -E "s/.?$i.?//g") continue - elif [ -d "$main_basedir"/all_statuses/$instance/*/$i ]; then + elif [ -n "$(7z e -so $main_basedir/archives/$instance.7z $i | cat)" ]; then + ids=$(echo "$ids" | sed -E "s/.?$i.?//g") + continue + elif [ -d "$main_basedir"/all_statuses/$instance/$i ]; then ids=$(echo "$ids" | sed -E "s/.?$i.?//g") continue fi diff --git a/utils/statuses2files_group.sh b/utils/statuses2files_group.sh index 2424e79..818e3c8 100755 --- a/utils/statuses2files_group.sh +++ b/utils/statuses2files_group.sh @@ -4,10 +4,21 @@ json=$(cat) +mkdir -p "$main_basedir/archives/" +unixtime_offset=$(expr $(date "+%s") - 86400) + for i in $ids; do status_id=$i acct=$(echo "$json" | jj "#[id=$i].account.acct") mkdir -m 711 -p "$main_basedir"/statuses/$instance/$acct + old_check=$(date +'%s' -r "$main_basedir"/all_statuses/$instance/$i/$i.json) + if [ $old_check -lt $unixtime_offset ]; then + 7z a -sdel "$main_basedir"/archives/$instance.7z "$main_basedir"/all_statuses/$instance/$i + echo "Olded status $i $(date -d "@$old_check") moved to archive" + ids=$(echo "$ids" | sed -E "s/.?$i.?//g") + continue + fi + if [ -n "$status_id" ]; then ln -v -s -r "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/statuses/$instance/$acct/$status_id