Moodle

Clean up files associated with a context when the context is deleted

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Files API
  • Labels:
    None
  • Difficulty:
    Easy
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

Clean up files associated with a context when the context is deleted

Issue Links

Activity

Hide
Sam Hemelryk added a comment -

Tiny patch that does uses delete_area_files as you suggested Petr,
Could you please have a quick check and if it's ok either commit it yourself or let me know and I'll check it in.
Cheers
Sam

Show
Sam Hemelryk added a comment - Tiny patch that does uses delete_area_files as you suggested Petr, Could you please have a quick check and if it's ok either commit it yourself or let me know and I'll check it in. Cheers Sam
Hide
Martin Dougiamas added a comment -

Which one is better:

1) Delete the files at the time the context is deleted
2) Leave the files, and add a cron job to clean up all orphaned files

I'm tending towards (2) simply because it fixes any cases where things get out of sync, and also allows context deletions to proceed quite fast.

Show
Martin Dougiamas added a comment - Which one is better: 1) Delete the files at the time the context is deleted 2) Leave the files, and add a cron job to clean up all orphaned files I'm tending towards (2) simply because it fixes any cases where things get out of sync, and also allows context deletions to proceed quite fast.
Hide
Martin Dougiamas added a comment -

Sam, can you implement the cron solution in head? It would just be a small bit of code in admin/cron.php to call a function in filelib.php.

Show
Martin Dougiamas added a comment - Sam, can you implement the cron solution in head? It would just be a small bit of code in admin/cron.php to call a function in filelib.php.
Hide
Sam Hemelryk added a comment -

Hi guys,
I have attached a patch that cleans up files that are associated with a context that no longer exists.
Could you please have a look at it and let me know what you think, I'm not sure this is the best way around the
task as it essentially requires the a file have a reference to a contextid that does not exist?
Cheers
Sam

Show
Sam Hemelryk added a comment - Hi guys, I have attached a patch that cleans up files that are associated with a context that no longer exists. Could you please have a look at it and let me know what you think, I'm not sure this is the best way around the task as it essentially requires the a file have a reference to a contextid that does not exist? Cheers Sam
Hide
Petr Škoda (skodak) added a comment -

+1 for commit

Show
Petr Škoda (skodak) added a comment - +1 for commit
Hide
Sam Hemelryk added a comment -

Will commit this on Wednesday as it is QA day today

Show
Sam Hemelryk added a comment - Will commit this on Wednesday as it is QA day today
Hide
Sam Hemelryk added a comment -

Has been commit now

Show
Sam Hemelryk added a comment - Has been commit now

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: