Working with files: Moodledata

Working with files: Moodledata

от Daniel Munera -
Number of replies: 3

Hi.

Question
-------------
How files and database's records are deleted when you are working with moodledata and external repositories?

Because I've seen that there are a lot of records that are saved when you store a new file and some of them are not deleted when you delete the file.

Context:
-----------

I have been working on a function to create a carousel of information to put it on my theme's frontpage.

The plugin is working fine, but I am worried about the quantity of records that are created when I update or create slides for the carousel.

I checked what happen when you add images on the summary section and there are much more records added to the mdl_files table than with my function.

But I still worried because I dont understand perfectly how Moodle delete draft files and maybe my draft files are not going to be deleted.

Thanks in advance,
Daniel.

 

 

In reply to Daniel Munera

Re: Working with files: Moodledata

от Davo Smith -
Снимка на Core developers Снимка на Particularly helpful Moodlers Снимка на Peer reviewers Снимка на Plugin developers

When you add a file to an empty area in Moodle, it also adds a 'folder' record to that area, with the name '/'. This is one source of 'extra' entries in the mdl_files table.

The draft files are kept around for a few days (a week?) and then automatically removed via a cron update.

Personally I'd not stress too much about lots of records in the mdl_files table - because of the way the filesystem works, each 'duplicate' entry in mdl_files ultimately points at the same file in your moodledata folder. By way of comparison, the table you most want to worry about getting too large (if you're dealing with a site with 10 000's of visitors per day), is the mdl_log table, as that is continually gaining new records, which are never deleted.

In reply to Davo Smith

Re: Working with files: Moodledata

от Séverin Terrier -
Снимка на Documentation writers Снимка на Particularly helpful Moodlers Снимка на Testers Снимка на Translators

About files duration before full deletion :

  • files in trashdir are deleted 24h after being in trashdir (if cron running).
  • files in draft are deleted after 4 days (and should NOT be deleted manually, because it could create data corruption/loss)

Information from Petr Škoda in MDL-25592 's comments.

Hope this helps
Séverin