1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace cachestore_file\task; 18 19 /** 20 * Task deletes old cache revision directory. 21 * 22 * @package cachestore_file 23 * @copyright Catalyst IT Europe Ltd 2021 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 * @author Jackson D'Souza <jackson.dsouza@catalyst-eu.net> 26 */ 27 class asyncpurge extends \core\task\adhoc_task { 28 29 /** 30 * Executes the scheduled task. 31 * 32 * @return boolean True if old cache revision directory exists and is deleted. False otherwise. 33 */ 34 public function execute(): bool { 35 36 $returnvar = true; 37 $output = 'Cleaning up file store old cache revision directory:' . PHP_EOL; 38 39 $data = $this->get_custom_data(); 40 if (is_dir($data->path)) { 41 remove_dir($data->path); 42 $output .= 'Directory deleted: ' . $data->path; 43 } else { 44 $output .= 'Directory not found: ' . $data->path; 45 $returnvar = false; 46 } 47 if (!PHPUNIT_TEST) { 48 mtrace($output); 49 } 50 return $returnvar; 51 } 52 53 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body