hey @sbs
I actually wrote a shell script to do this for us. What it does is move/delete the files from the location on disk, and then uses the Cells CLI tool to run a datasource synchronization that repairs the database.I know it’s not the “API based solution” I was hoping for when I posted this question, but it does work well.
This is the script:
#!/bin/bash
#
# This script will move files older than 30 days to recyclebin
# NOTE files inside folders with a name that starts with "/lts-" will not be moved.
# "lts-" folders are considered "Long Term Storage" and are exempt from this script.
#
shopt -s globstar
if [ "$USER" != "pydio" ]; then
echo "Please run this script as pydio user"
#exit
fi
#Empty the previous recyclebin
rm /home/pydio/recyclebin/*
#Obtain timestamp -30 days
pastdate=$(date -d "$date -30 days" '+%s')
#Loop through all files/folders
for file in /home/pydio/.config/pydio/cells/data/cellsdata/**
do
#Use perl to match file paths that do not contain "/lts-"
match=$(echo "${file}" | perl -0777 -pe 's/^(?:(?!\/lts-).)+$/match/i')
#Get type, directory | regular file
filetype=`stat -c %F "$file"`
#If its a good path and file then
if [ "$match" == "match" ] && [ "$filetype" == "regular file" ]; then
#Get the mtime timestamp
filemtime=`stat -c %Y "$file"`
#If the file mtime is older or equal to the comparison date, delete it
if [ $filemtime -le $pastdate ]; then
echo "$file"
mv "$file" /home/pydio/recyclebin/
#rm "$file"
fi
fi
done
/home/pydio/cells admin resync --datasource=cellsdata
echo "****"
echo "Script finished. Please verify cellsdata resync in the logs."
echo "****"