You are here

function drush_epub_flush in Epub 8

Same name and namespace in other branches
  1. 7 epub.drush.inc \drush_epub_flush()

Reset file mime type for epub files.

Parameters

null $fid1:

null $fid2:

Return value

bool

File

drush/epub.drush.inc, line 35
Contains epub drush commands.

Code

function drush_epub_flush($fid1 = NULL, $fid2 = NULL) {
  $query = db_select('file_managed', 'fid')
    ->fields('fid', array(
    'fid',
  ));
  if (is_numeric($fid1)) {
    $query
      ->condition('fid', $fid1, '>=');
    if (is_numeric($fid2)) {
      if ($fid2 > $fid1) {
        $query
          ->condition('fid', $fid2, '<=');
      }
      else {
        drush_set_error('Make sure fid1 < fid2.');
        return False;
      }
    }
  }
  foreach ($query
    ->execute()
    ->fetchCol() as $fid) {
    $file = file_load($fid);
    if (epub_reset_mimetype($file)) {
      drush_log(dt('File @fid: mimetype was reset.', array(
        '@fid' => $file->fid,
      )), 'ok');
    }
  }
}