diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2018-04-18 14:36:35 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2018-04-18 14:36:35 +0200 |
commit | 7e61a4b4f1184657289555d8112226c77ffcf1b7 (patch) | |
tree | dd4f0c53b343cf4428cb35e474b37cd696d96f4b /odin/strm/cleanup_youtube | |
parent | 12ee11496fbb107abda7c40e7bb4b1cbcb8c942c (diff) | |
download | nixos-7e61a4b4f1184657289555d8112226c77ffcf1b7.tar nixos-7e61a4b4f1184657289555d8112226c77ffcf1b7.tar.gz nixos-7e61a4b4f1184657289555d8112226c77ffcf1b7.tar.bz2 nixos-7e61a4b4f1184657289555d8112226c77ffcf1b7.tar.xz nixos-7e61a4b4f1184657289555d8112226c77ffcf1b7.zip |
Nicer utils
Diffstat (limited to 'odin/strm/cleanup_youtube')
-rw-r--r-- | odin/strm/cleanup_youtube | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/odin/strm/cleanup_youtube b/odin/strm/cleanup_youtube index 2d91fe1f..76c3f0bb 100644 --- a/odin/strm/cleanup_youtube +++ b/odin/strm/cleanup_youtube | |||
@@ -19,19 +19,7 @@ function cleanup { | |||
19 | 19 | ||
20 | urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } | 20 | urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } |
21 | 21 | ||
22 | dir=/srv/media/youtube | 22 | @rollingdirectory@/bin/rolling-directory /srv/media/youtube 50Gi |
23 | maxsize=$((1024 * 1024 * 1024 * 50)) | ||
24 | |||
25 | while [[ $(du -bs $dir | awk '{ print $1; }') -gt $maxsize ]]; do | ||
26 | find $dir -type f -not -path $dir/CACHEDIR.TAG -print0 | \ | ||
27 | xargs -0 -- stat --printf '%W %Y %Z %X %n\0' | \ | ||
28 | sort -t '\0' -z | \ | ||
29 | awk -F '\0' '{ gsub("^\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s+", "", $1); printf "%s\0", $1; }' | \ | ||
30 | xargs -0 -- rm -v | ||
31 | done | ||
32 | |||
33 | find $dir -xtype l -delete | ||
34 | find $dir -type d -empty -delete | ||
35 | 23 | ||
36 | notmuch search --output=messages --format=text 'is:cached' | \ | 24 | notmuch search --output=messages --format=text 'is:cached' | \ |
37 | while read id; do | 25 | while read id; do |