File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 8383
8484commands_count=0
8585if [ -d " $COMMANDS_DIR " ]; then
86- commands_count=$( find " $COMMANDS_DIR " -maxdepth 1 -name ' *.md' | wc -l | tr -d ' ' )
86+ commands_count=$( find " $COMMANDS_DIR " -type f -name ' *.md' 2> /dev/null | wc -l | tr -d ' ' )
8787fi
8888
8989pending_count=0
9090if [ -d " $PENDING_DIR " ]; then
91- pending_count=$( find " $PENDING_DIR " -maxdepth 1 -name ' *.json' | wc -l | tr -d ' ' )
91+ pending_count=$( find " $PENDING_DIR " -type f -name ' *.json' 2> /dev/null | wc -l | tr -d ' ' )
9292fi
9393
9494profile_belt=" unknown"
Original file line number Diff line number Diff line change @@ -80,8 +80,14 @@ if [ -d "$PENDING_DIR" ] && [ "$(ls -A "$PENDING_DIR" 2>/dev/null)" ]; then
8080 # Clear the pending queue
8181 rm -f " $PENDING_DIR " /* .json
8282
83- # Cap archive size: keep only last 30 days of archives (~1MB)
84- find " $ARCHIVE_DIR " -name " *.jsonl" -type f | sort | head -n -30 | xargs -r rm -f
83+ # Cap archive size: keep only the latest 30 daily archives
84+ ARCHIVE_COUNT=$( find " $ARCHIVE_DIR " -name " *.jsonl" -type f | wc -l | tr -d ' ' )
85+ if [ " $ARCHIVE_COUNT " -gt 30 ]; then
86+ REMOVE_COUNT=$(( ARCHIVE_COUNT - 30 ))
87+ find " $ARCHIVE_DIR " -name " *.jsonl" -type f | sort | head -n " $REMOVE_COUNT " | while IFS= read -r archive_file; do
88+ [ -n " $archive_file " ] && rm -f " $archive_file "
89+ done
90+ fi
8591fi
8692
8793rm -f " $SESSION_STATE "
You can’t perform that action at this time.
0 commit comments