function cleanUpUpdatesDir(aBackgroundUpdate) {
  // Bail out if we don't have appropriate permissions
  try {
    var updateDir = getUpdatesDir();
  }
  catch (e) {
    return;
  }

  var e = updateDir.directoryEntries;
  while (e.hasMoreElements()) {
    var f = e.getNext().QueryInterface(Ci.nsIFile);
    // Preserve the last update log file for debugging purposes
    if (f.leafName == FILE_UPDATE_LOG) {
      var dir;
      try {
//@line 762 "e:\builds\moz2_slave\rel-m-rel-xr-w32-bld\build\toolkit\mozapps\update\nsUpdateService.js"
        // If we're on a platform which uses the update root directory, the log
        // files are written outside of the application directory, so they will
        // not get overwritten when we replace the directories after a
        // background update.  Therefore, we don't need any special logic for
        // that case here.
        // Note that this currently only applies to Windows.
        dir = f.parent.parent;
//@line 781 "e:\builds\moz2_slave\rel-m-rel-xr-w32-bld\build\toolkit\mozapps\update\nsUpdateService.js"
        var logFile = dir.clone();
        logFile.append(FILE_LAST_LOG);
        if (logFile.exists()) {
          try {
            logFile.moveTo(dir, FILE_BACKUP_LOG);
          }
          catch (e) {
            LOG("cleanUpUpdatesDir - failed to rename file " + logFile.path +
                " to " + FILE_BACKUP_LOG);
          }
        }
        f.moveTo(dir, FILE_LAST_LOG);
        if (aBackgroundUpdate) {
          // We're not going to delete any files, so we can just
          // bail out of the loop right now.
          break;
        } else {
          continue;
        }
      }
      catch (e) {
        LOG("cleanUpUpdatesDir - failed to move file " + f.path + " to " +
            dir.path + " and rename it to " + FILE_LAST_LOG);
      }
    } else if (aBackgroundUpdate) {
      // Don't delete any files when an update has been staged, as
      // we need to keep them around in case we would have to fall
      // back to applying the update on application restart.
      continue;
    }
    // Now, recursively remove this file.  The recursive removal is really
    // only needed on Mac OSX because this directory will contain a copy of
    // updater.app, which is itself a directory.
    try {
      f.remove(true);
    }
    catch (e) {
      LOG("cleanUpUpdatesDir - failed to remove file " + f.path);
    }
  }
}
/**
 * Removes the contents of the Updates Directory
 *
 * @param aBackgroundUpdate Whether the update has been performed in the
 *        background.  If this is true, we move the update log file to the
 *        updated directory, so that it survives replacing the directories
 *        later on.
 */
Removes the contents of the Updates Directory
@param aBackgroundUpdate Whether the update has been performed in the
background.  If this is true, we move the update log file to the
updated directory, so that it survives replacing the directories
later on.
Removes the contents of the Updates Directory @param aBackgroundUpdate Whether the update has been performed in the background . If this is true we move the update log file to the updated directory so that it survives replacing the directories later on .
function cleanUpUpdatesDir(aBackgroundUpdate) {
  try {
    var updateDir = getUpdatesDir();
  }
  catch (e) {
    return;
  }
  var e = updateDir.directoryEntries;
  while (e.hasMoreElements()) {
    var f = e.getNext().QueryInterface(Ci.nsIFile);
    if (f.leafName == FILE_UPDATE_LOG) {
      var dir;
      try {
        dir = f.parent.parent;
        var logFile = dir.clone();
        logFile.append(FILE_LAST_LOG);
        if (logFile.exists()) {
          try {
            logFile.moveTo(dir, FILE_BACKUP_LOG);
          }
          catch (e) {
            LOG("cleanUpUpdatesDir - failed to rename file " + logFile.path +
                " to " + FILE_BACKUP_LOG);
          }
        }
        f.moveTo(dir, FILE_LAST_LOG);
        if (aBackgroundUpdate) {
          break;
        } else {
          continue;
        }
      }
      catch (e) {
        LOG("cleanUpUpdatesDir - failed to move file " + f.path + " to " +
            dir.path + " and rename it to " + FILE_LAST_LOG);
      }
    } else if (aBackgroundUpdate) {
      continue;
    }
    try {
      f.remove(true);
    }
    catch (e) {
      LOG("cleanUpUpdatesDir - failed to remove file " + f.path);
    }
  }
}
function cleanUpUpdatesDir ( aBackgroundUpdate ) { try { var updateDir = getUpdatesDir ( ) ; } catch ( e ) { return ; } var e = updateDir . directoryEntries ; while ( e . hasMoreElements ( ) ) { var f = e . getNext ( ) . QueryInterface ( Ci . nsIFile ) ; if ( f . leafName == FILE_UPDATE_LOG ) { var dir ; try { dir = f . parent . parent ; var logFile = dir . clone ( ) ; logFile . append ( FILE_LAST_LOG ) ; if ( logFile . exists ( ) ) { try { logFile . moveTo ( dir , FILE_BACKUP_LOG ) ; } catch ( e ) { LOG ( "cleanUpUpdatesDir - failed to rename file " + logFile . path + " to " + FILE_BACKUP_LOG ) ; } } f . moveTo ( dir , FILE_LAST_LOG ) ; if ( aBackgroundUpdate ) { break ; } else { continue ; } } catch ( e ) { LOG ( "cleanUpUpdatesDir - failed to move file " + f . path + " to " + dir . path + " and rename it to " + FILE_LAST_LOG ) ; } } else if ( aBackgroundUpdate ) { continue ; } try { f . remove ( true ) ; } catch ( e ) { LOG ( "cleanUpUpdatesDir - failed to remove file " + f . path ) ; } } }
Removes the contents of the Updates Directory
 @param aBackgroundUpdate Whether the update has been performed in the
        background.
Removes the contents of the Updates Directory @param aBackgroundUpdate Whether the update has been performed in the background .
// Bail out if we don't have appropriate permissions // Preserve the last update log file for debugging purposes //@line 762 "e:\builds\moz2_slave\rel-m-rel-xr-w32-bld\build\toolkit\mozapps\update\nsUpdateService.js" // If we're on a platform which uses the update root directory, the log // files are written outside of the application directory, so they will // not get overwritten when we replace the directories after a // background update.  Therefore, we don't need any special logic for // that case here. // Note that this currently only applies to Windows. //@line 781 "e:\builds\moz2_slave\rel-m-rel-xr-w32-bld\build\toolkit\mozapps\update\nsUpdateService.js" // We're not going to delete any files, so we can just // bail out of the loop right now. // Don't delete any files when an update has been staged, as // we need to keep them around in case we would have to fall // back to applying the update on application restart. // Now, recursively remove this file.  The recursive removal is really // only needed on Mac OSX because this directory will contain a copy of // updater.app, which is itself a directory.