mirror of
http://gitea.phreedom.club/localhost_frssoft/pleroma-cli
synced 2024-11-25 21:21:26 +00:00
Refactor file builder; mv -> ln; fix dublicate scan
This commit is contained in:
parent
f9097b559f
commit
d29a97b19c
|
@ -1,30 +1,29 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Extract fields from statuses
|
||||
check_ids=$(echo "$main_basedir"/statuses/$instance/*/*.json)
|
||||
if [ ! -n "$check_ids" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for i in "$main_basedir"/statuses/$instance/*/*.json; do
|
||||
json=$(cat)
|
||||
|
||||
for i in $ids; do
|
||||
# Required fields
|
||||
status_id=$(jj -i $i 'id')
|
||||
status_date=$(jj -i $i 'created_at')
|
||||
status_id=$(echo "$json" | jj "#[id=$i].id")
|
||||
status_date=$(echo "$json" | jj "#[id=$i].created_at")
|
||||
|
||||
# Fields
|
||||
content=$(jj -i $i content | "$main_basedir"/utils/html_to_txt_render)
|
||||
status_media_attachments=$(jj -i $i -l 'media_attachments.#.url' | tr -d '"\v')
|
||||
content=$(echo "$json" | jj "#[id=$i].content" | "$main_basedir"/utils/html_to_txt_render)
|
||||
status_media_attachments=$(echo "$json" | jj -l "#[id=$i].media_attachments.#.url" | tr -d '"\v')
|
||||
|
||||
chmod 711 "$main_basedir"/statuses/$instance/$status_id
|
||||
touch -d "$status_date" "$main_basedir"/statuses/$instance/$status_id
|
||||
chmod 711 "$main_basedir"/all_statuses/$instance/$status_id
|
||||
touch -d "$status_date" "$main_basedir"/all_statuses/$instance/$status_id
|
||||
|
||||
if [ -n "$content" ]; then
|
||||
echo "$content" > "$main_basedir"/statuses/$instance/$status_id/content
|
||||
echo "$content" > "$main_basedir"/all_statuses/$instance/$status_id/content
|
||||
fi
|
||||
if [ -n "$status_media_attachments" ]; then
|
||||
echo "$status_media_attachments" > "$main_basedir"/statuses/$instance/$status_id/media_attachments.m3u8
|
||||
echo "$status_media_attachments" > "$main_basedir"/all_statuses/$instance/$status_id/media_attachments.m3u8
|
||||
fi
|
||||
chmod 600 "$main_basedir"/statuses/$instance/$status_id/*
|
||||
chmod 600 "$main_basedir"/all_statuses/$instance/$status_id/*
|
||||
done
|
||||
|
||||
"$main_basedir"/utils/statuses2files_acct.sh
|
||||
export ids
|
||||
echo "$json" | "$main_basedir"/utils/statuses2files_acct.sh
|
||||
|
|
|
@ -4,18 +4,20 @@
|
|||
json="$(cat)"
|
||||
ids=$(echo "$json" | jj -l '#.id' | sed 's/"//g')
|
||||
|
||||
if [ ! -d "$main_basedir/statuses/$instance" ]; then
|
||||
mkdir -p "$main_basedir/statuses/$instance"
|
||||
fi
|
||||
mkdir -p "$main_basedir/all_statuses/$instance"
|
||||
mkdir -p "$main_basedir/statuses/$instance"
|
||||
|
||||
for i in $ids; do
|
||||
if [ -f "$main_basedir"/statuses/$instance/$i/$i.json ]; then
|
||||
if [ -f "$main_basedir"/all_statuses/$instance/$i/$i.json ]; then
|
||||
ids=$(echo "$ids" | sed -E "s/.?$i.?//g")
|
||||
continue
|
||||
elif [ -d "$main_basedir"/statuses/$instance/*/$i ]; then
|
||||
elif [ -d "$main_basedir"/all_statuses/$instance/*/$i ]; then
|
||||
ids=$(echo "$ids" | sed -E "s/.?$i.?//g")
|
||||
continue
|
||||
fi
|
||||
mkdir -m 711 -p "$main_basedir"/statuses/$instance/$i
|
||||
echo "$json" | jj -p "#[id=$i]" > "$main_basedir"/statuses/$instance/$i/$i.json
|
||||
mkdir -m 711 -p "$main_basedir"/all_statuses/$instance/$i
|
||||
echo "$json" | jj -p "#[id=$i]" > "$main_basedir"/all_statuses/$instance/$i/$i.json
|
||||
done
|
||||
|
||||
"$main_basedir"/utils/extract_fields_statuses.sh
|
||||
export ids
|
||||
echo "$json" | "$main_basedir"/utils/extract_fields_statuses.sh
|
||||
|
|
|
@ -9,12 +9,14 @@
|
|||
# | |--- ...
|
||||
# |...
|
||||
|
||||
for i in "$main_basedir"/statuses/$instance/*/*.json; do
|
||||
status_id=$(jj -i $i 'id')
|
||||
acct=$(jj -i $i 'account.acct')
|
||||
json=$(cat)
|
||||
|
||||
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
|
||||
if [ -n "$status_id" ]; then
|
||||
mv "$main_basedir"/statuses/$instance/$status_id "$main_basedir"/statuses/$instance/$acct
|
||||
ln -s -r "$main_basedir"/all_statuses/$instance/$status_id "$main_basedir"/statuses/$instance/$acct/$status_id
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in a new issue