9 lines
652 B
Bash
Executable file
9 lines
652 B
Bash
Executable file
#!/bin/zsh
|
|
|
|
# Get all files so we can delete them later
|
|
files=$(sudo -iu postgres psql -d e2net -c "SELECT \"url\" FROM \"public\".\"drive_file\" WHERE \"isLink\" = 'FALSE' AND \"storedInternal\" = 'FALSE' UNION ALL SELECT \"thumbnailUrl\" FROM \"public\".\"drive_file\" WHERE \"isLink\" = 'FALSE' AND \"storedInternal\" = 'FALSE'" -t -A --csv | sed 's/https:\/\/e2net.cdn.ztn.sh\/drive\///g' | awk NF | sort)
|
|
|
|
miniofiles=$(mcli ls garage/e2net/drive | grep -Po '[^\s]*$' | grep -Pv '^webpublic-' | sort)
|
|
|
|
comm -23 <(echo "$miniofiles") <(echo "$files") | sed 's/^/garage\/e2net\/drive\//g' | grep -P '\/e2net\/drive\/.{16,}' | mcli rm --stdin --force
|