Bug 491436 - Some logging improvements to update service. r=rstrong
authorJeff Beckley <beckley@qualcomm.com>
Tue, 19 May 2009 13:24:59 -0700
changeset 28598 25483465753c6d48865e8d00048384d90395b984
parent 28597 371be45fedd12ba2d504cc610c6afed77dcae2b4
child 28600 440707c4cc9b55dc944e53e0aa0d3d22f54193e3
push id7135
push userrstrong@mozilla.com
push dateTue, 19 May 2009 20:25:22 +0000
treeherdermozilla-central@25483465753c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs491436
milestone1.9.2a1pre
Bug 491436 - Some logging improvements to update service. r=rstrong
toolkit/mozapps/update/src/nsUpdateService.js.in
--- a/toolkit/mozapps/update/src/nsUpdateService.js.in
+++ b/toolkit/mozapps/update/src/nsUpdateService.js.in
@@ -358,33 +358,38 @@ function getUpdatesDir(key) {
     try {
       updateDir = fileLocator.get(KEY_UPDROOT, Ci.nsIFile);
     } catch (e) {
     }
 #endif
   }
   updateDir.append(DIR_UPDATES);
   updateDir.append("0");
-  if (!updateDir.exists() && !key)
+  if (!updateDir.exists() && !key) {
+    LOG("General", "getUpdatesDir - update directory " + updateDir.path +
+        " doesn't exist, creating...");
     updateDir.create(Ci.nsILocalFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
+  }
   return updateDir;
 }
 
 /**
  * Reads the update state from the update.status file in the specified
  * directory.
  * @param   dir
  *          The dir to look for an update.status file in
  * @returns The status value of the update.
  */
 function readStatusFile(dir) {
   var statusFile = dir.clone();
   statusFile.append(FILE_UPDATE_STATUS);
-  LOG("General", "readStatusFile - Reading Status File: " + statusFile.path);
-  return readStringFromFile(statusFile) || STATE_NONE;
+  var status = readStringFromFile(statusFile) || STATE_NONE;
+  LOG("General", "readStatusFile - status: " + status + ", path: " +
+      statusFile.path);
+  return status;
 }
 
 /**
  * Writes the current update operation/state to a file in the patch
  * directory, indicating to the patching system that operations need
  * to be performed.
  * @param   dir
  *          The patch directory where the update.status file should be
@@ -465,16 +470,18 @@ function cleanUpUpdatesDir(key) {
   }
   try {
     updateDir.remove(false);
   } catch (e) {
     LOG("General", "cleanUpUpdatesDir - failed to remove update directory: " +
         updateDir.path + " - This is almost always bad. Exception = " + e);
     throw e;
   }
+  LOG("General", "cleanUpUpdatesDir - successfully removed update directory: " +
+      updateDir.path);
 }
 
 /**
  * Clean up updates list and the updates directory.
  * @param   key
  *          The Directory Service Key under which update directory resides
  *          (optional).
  */
@@ -635,18 +642,20 @@ function writeStringToFile(file, text) {
 /**
  * Reads a string of text from a file.  A trailing newline will be removed
  * before the result is returned.  This function only works with ASCII text.
  */
 function readStringFromFile(file) {
   var fis = Cc["@mozilla.org/network/file-input-stream;1"].
             createInstance(Ci.nsIFileInputStream);
   var modeFlags = MODE_RDONLY;
-  if (!file.exists())
+  if (!file.exists()) {
+    LOG("General", "readStringFromFile - file doesn't exist: " + file.path);
     return null;
+  }
   fis.init(file, modeFlags, PERMS_FILE, 0);
   var sis = Cc["@mozilla.org/scriptableinputstream;1"].
             createInstance(Ci.nsIScriptableInputStream);
   sis.init(fis);
   var text = sis.read(sis.available());
   sis.close();
   if (text[text.length - 1] == "\n")
     text = text.slice(0, -1);