How to properly manual delete the remaining 'assignfeedback_editpdf' after uninstalling the AnnotatePDF plugin

Re: How to properly manual delete the remaining 'assignfeedback_editpdf' after uninstalling the AnnotatePDF plugin

by Achim Raphael -
Number of replies: 8

This is a longer known, annoying bug in this plugin:
https://tracker.moodle.org/browse/MDL-69570

I can't understand why it isn't still not fixed.
In our moodle we have to clean up these orphaned files (10GB every week) continuously with moosh and bash-shellscripts. sad

In reply to Achim Raphael

Re: How to properly manual delete the remaining 'assignfeedback_editpdf' after uninstalling the AnnotatePDF plugin

by Hariharasudhan A S -
Hi, I am facing the same problem. Could you please share the script your are using. Thanks
In reply to Hariharasudhan A S

Re: How to properly manual delete the remaining 'assignfeedback_editpdf' after uninstalling the AnnotatePDF plugin

by Achim Raphael -
Hi

The scripts are too specific to our installation to share them, but I can tell you how I do it:

First I get a list of the ids of all courses in the category, from which I want to purge all editpdf-files:
moosh -n -p $moodlepath -c $catid | awk -F, '{ print $1 }' | tr -d \" >$tmpfile
(You can use moosh -n category-list $category-name to find a categories id)

Then I scan these courses for the editpdf-files:

rm $editpdffiles 2>/dev/null
i=0
while read -r cid; do
i=$((i + 1))
[ $i -eq 1 ] && continue;
moosh -n -p $moodlepath file-list course=$cid \
| grep -e "assignfeedback_editpdf" \
| grep -v -e ":stamps:" \
>>$editpdffiles
done < $tmpfile

This gives a list of all these files. Here a sample line:
1581580 0 .... f111716a9e35eea8aa735106e3cba13857eae832 Saturday, 10. April 2021, 10:13 77645:assignfeedback_editpdf:combined:40147 combined.pdf
---

You can now purge all these files (or filter them before by date as I do)
cat $editpdffiles | moosh -n -p $moodlepath file-delete -s

Hope it helps a bit.

But be careful and check all twice, so you not delete something wrong wink
Average of ratings: Useful (1)
In reply to Hariharasudhan A S

Re: How to properly manual delete the remaining 'assignfeedback_editpdf' after uninstalling the AnnotatePDF plugin

by Christian Stickel -

I don't have moosh installed, so my approach is different, although still using bash. It assumes that you have a separate DB Server to connect through ssh, but that can be changed easily. The select statement creates a deletelist shellscript which is then executed and removes the physical files. Afterwards the db entries in mdl_files are removed.

mytime="1 YEAR"
sqluser"yourusername"
sqlPW="yourpassword"

#create deletelist script
ssh user@yourserver "mysql -u$sqluser -p$sqlPW yourmoodle_db -e \"SELECT DISTINCT CONCAT('rm -f /path/to/moodledata/filedir/', LEFT(mdl_files.contenthash, 2),'/', MID(mdl_files.contenthash, 3, 2),'/', mdl_files.contenthash,';') AS shellscript FROM mdl_files WHERE component = 'assignfeedback_editpdf' AND timecreated < UNIX_TIMESTAMP(DATE_SUB(NOW(),INTERVAL $mytime));\"" > clear.sh;

#modify and execute deletelist script
sed -i '1d' clear.sh
chmod +x clear.sh
/path/to/clear.sh;

#delete database entries
ssh user@yourserver "mysql -u$sqluser -p$sqlPW yourmoodle_db -e \"DELETE FROM mdl_files WHERE component = 'assignfeedback_editpdf' AND timecreated < UNIX_TIMESTAMP(DATE_SUB(NOW(),INTERVAL $mytime));\"";

Average of ratings: Useful (3)
In reply to Christian Stickel

Re: How to properly manual delete the remaining 'assignfeedback_editpdf' after uninstalling the AnnotatePDF plugin

by Achim Raphael -
Nice.
Is anyone able to write a moodleplugin doing this?
Then this could be used via backend by those who don't have access to the server.
Average of ratings: Useful (2)
In reply to Achim Raphael

Re: How to properly manual delete the remaining 'assignfeedback_editpdf' after uninstalling the AnnotatePDF plugin

by Tyler Bogdan -
I've done a bit of cleaning of these files (ones that are 4-5 years old) but it still makes me nervous to do so. What exactly are their purpose? We actively use AnnotatePDF and I don't want to delete files that are being relied upon for the plugin to function or for students to view feedback on their assignments.
In reply to Tyler Bogdan

Re: How to properly manual delete the remaining 'assignfeedback_editpdf' after uninstalling the AnnotatePDF plugin

by Achim Raphael -
In reply to Achim Raphael

Re: How to properly manual delete the remaining 'assignfeedback_editpdf' after uninstalling the AnnotatePDF plugin

by Jose Miralles -
Hi there!
Is there any fix now of this issue without coding for those we are afraid of doing it?
In reply to Achim Raphael

Re: How to properly manual delete the remaining 'assignfeedback_editpdf' after uninstalling the AnnotatePDF plugin

by Johnny Lo -
We are running 3.11.9+ on IIS and MS SQL 2019. Can anyone provide a quick guideline on how to merge the fix to the current local branch? I started to use Git to upgrade moodle a couple of times already but can definitely use some guidiance in merging fixes.
Average of ratings: Useful (1)