You are here

function brilliant_gallery_cleantmpdir in Brilliant Gallery 6.4

Same name and namespace in other branches
  1. 6.3 brilliant_gallery.module \brilliant_gallery_cleantmpdir()
  2. 7 brilliant_gallery_cron.inc \brilliant_gallery_cleantmpdir()
1 call to brilliant_gallery_cleantmpdir()
brilliant_gallery_cron in ./cron.inc

File

./cron.inc, line 25

Code

function brilliant_gallery_cleantmpdir() {

  // Delete files and directories from the file cache directory if their time is up!
  $timenow = time();
  $bgcachexpire = brilliant_gallery_get_days_in_seconds(variable_get('brilliant_gallery_cache_duration', 90));
  $timestampexpired = time() - $bgcachexpire;
  $cachetempdirectory = variable_get('brilliant_gallery_pcache', BRILLIANT_GALLERY_DEFAULT_CACHE_DIR);

  //brilliant_gallery_check_or_create_dir($cachetempdirectory);

  /*
  if ($cachetempdirectory == ''){
      // If there is no cache directory in the files folder, then we need to use the default temp dir
      $cachetempdirectory = file_directory_temp();
  } else {
      $cachetempdirectory = realpath(file_directory_path()) . '/' . $cachetempdirectory;
  }
  */
  $cachetempdirectory = realpath(file_directory_path()) . '/' . $cachetempdirectory;
  $GLOBALS['bg_removedcnt'] = 0;

  #watchdog('Brilliant Gal','sakr2: '.$cachetempdirectory);

  #watchdog('Brilliant Gal Cron','in');
  brilliant_gallery_rmdir_recursive($cachetempdirectory, $timestampexpired);

  // Also clear the Drupal cache - otherwise there might be some cached HTML pointing to files that are no longer in the file cache.
  cache_clear_all();
  watchdog('Brilliant Gal', 'Cleared ' . $GLOBALS['bg_removedcnt'] . ' files from the temp directory ' . $cachetempdirectory . ' after ' . variable_get('brilliant_gallery_cache_duration', 90) . ' days. Elapsed time: ' . (time() - $timenow) . ' seconds.');
}