Hello :)
I'm just curious if it's normal that many html and html.gz files, which are older versions of the pages are left in cache folders...
Is there a limit that one can set as to how many older versions of the page created by boost are kept on the server?
For example my main page has always 2 updated files: _.html and _htmal.gz but then it has many files that end like: _.html.gz20374old and _.html12138old .
Ela

CommentFileSizeAuthor
#4 boost-942224.patch2.04 KBmikeytown2
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

Server on windows? what's your file system?

Code in question; looks like I need to handle rename failures better.


/**
 * Writes data to filename in an atomic operation thats compatible with older
 * versions of php (php < 5.2.4 file_put_contents() doesn't lock correctly).
 *
 * @param $filename
 *   Name of file to be written
 * @param $buffer
 *   Contents of file
 */
function boost_cache_write($filename, $buffer) {
  $filenames = boost_get_all_filenames($filename);
  foreach ($filenames as $key => $values) {
    if ($key == 'gzip') {
      $data = gzencode($buffer, 9);
    }
    else {
      $data = $buffer;
    }
    foreach ($values as $filename) {
      if (!_boost_mkdir_p(dirname($filename))) {
        if (BOOST_VERBOSE >= 3) {
          watchdog('boost', 'Unable to create directory: %dir<br /> Group ID: %gid<br /> User ID: %uid<br /> Current script owner: %user<br />', array('%dir' => dirname($filename), '%gid' => getmygid(), '%uid' => getmyuid(), '%user' => get_current_user()), WATCHDOG_WARNING);
        }
      }
      $tempfile = $filename . getmypid();
      if (@file_put_contents($tempfile, $data) === FALSE) {
        if (BOOST_VERBOSE >= 3) {
          watchdog('boost', 'Unable to write temp file: %file<br /> Group ID: %gid<br /> User ID: %uid<br /> Current script owner: %user<br />', array('%file' => $tempfile, '%gid' => getmygid(), '%uid' => getmyuid(), '%user' => get_current_user()), WATCHDOG_WARNING);
        }
        return FALSE;
      }
      else {
        if (is_numeric(BOOST_PERMISSIONS_FILE)) {
          @chmod($tempfile, octdec(BOOST_PERMISSIONS_FILE));
        }
        // Erase old file
        if (BOOST_OVERWRITE_FILE) {
          @rename($filename, $tempfile . 'old');
        }
        // Put temp file in its final location
        if (@rename($tempfile, $filename) === FALSE) {
          @unlink($tempfile);
          @rename($tempfile . 'old', $filename);
          if (BOOST_VERBOSE >= 5) {
            watchdog('boost', 'Unable to rename file: %temp  to  %file<br /> Group ID: %gid<br /> User ID: %uid<br /> Current script owner: %user<br />', array('%temp' => $tempfile, '%file' => $filename, '%gid' => getmygid(), '%uid' => getmyuid(), '%user' => get_current_user()), WATCHDOG_WARNING);
          }
          return FALSE;
        }
        elseif (BOOST_OVERWRITE_FILE) {
          @unlink($tempfile . 'boost');
        }
      }
    }
  }
  return TRUE;
}

mikeytown2’s picture

Issue tags: +1.19 Release Blocker
Ela’s picture

on my status reposts it says:
File system: Writable (public download method)
Web server: Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 mod_fcgid/2.3.5

mikeytown2’s picture

Status: Active » Needs review
FileSize
2.04 KB
mikeytown2’s picture

Ela’s picture

Thank you for such quick fix! :)
Works great! Thank you again for providing this module :)

Status: Fixed » Closed (fixed)
Issue tags: -1.19 Release Blocker

Automatically closed -- issue fixed for 2 weeks with no activity.