diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-12-28 19:11:31 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-12-28 19:11:31 +0000 |
commit | 53b83cdcb99531a73765f31301a8dba2d9d0252c (patch) | |
tree | 96d5141470fd77226ca772a321f42ad4c421a178 /modules/system/system.module | |
parent | 48673b7506cadf7754b6e047b1fd9e77f3e8fea4 (diff) | |
download | brdo-53b83cdcb99531a73765f31301a8dba2d9d0252c.tar.gz brdo-53b83cdcb99531a73765f31301a8dba2d9d0252c.tar.bz2 |
- Patch #330633 by drewish: temporary file clean-up _and_ unit tests. Oh yeah.
Diffstat (limited to 'modules/system/system.module')
-rw-r--r-- | modules/system/system.module | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/modules/system/system.module b/modules/system/system.module index cc5282a96..00cd10c03 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1513,18 +1513,15 @@ function system_cron() { db_query('DELETE FROM {batch} WHERE timestamp < %d', REQUEST_TIME - 864000); // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE. - $result = db_query('SELECT * FROM {files} WHERE status = %d and timestamp < %d', FILE_STATUS_TEMPORARY, REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE); - while ($file = db_fetch_object($result)) { - if (file_exists($file->filepath)) { - // If files that exist cannot be deleted, continue so the database remains - // consistent. + $result = db_query('SELECT fid FROM {files} WHERE status & :permanent != :permanent AND timestamp < :timestamp', array(':permanent' => FILE_STATUS_PERMANENT, ':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE)); + foreach ($result as $row) { + if ($file = file_load($row->fid)) { if (!file_delete($file)) { watchdog('file system', 'Could not delete temporary file "%path" during garbage collection', array('%path' => $file->filepath), WATCHDOG_ERROR); - continue; } } - db_query('DELETE FROM {files} WHERE fid = %d', $file->fid); } + $core = array('cache', 'cache_block', 'cache_filter', 'cache_page', 'cache_form', 'cache_menu'); $cache_tables = array_merge(module_invoke_all('flush_caches'), $core); foreach ($cache_tables as $table) { |