ambevar-dotfiles/.mutt/purgecache.sh

21 lines
476 B
Bash
Executable File

#!/bin/sh
## Purge old messages in Mutt's message cache.
## "$1" is cache location.
## This is intended to be run at startup, but can be run manually anytime.
## It should not output anything to stdout.
## In KB.
CACHE_LIMIT=102400
cd "$1" 2>/dev/null
[ $? -ne 0 ] && exit
[ $(du -s . | cut -f1 -d' ') -lt $CACHE_LIMIT ] && exit
while IFS= read -r i; do
rm "$i"
[ $(du -s . | cut -f1 -d' ') -lt $CACHE_LIMIT ] && exit
done <<EOF
$(find . -type f -exec ls -rt1 {} +)
EOF