bug 714168 - make reftest-remote seems to fail on tablets because nsLocalFileUnix throws exceptions when setting file permissions on a FAT file system r=mossop,unfocussed
☠☠ backed out by 2b74b62701e2 ☠ ☠
authorBrad Lassey <blassey@mozilla.com>
Wed, 25 Jan 2012 03:24:52 -0500
changeset 86656 f583132674d5ab623bde7aa46c8e6d8db9c721b1
parent 86655 50912fc183283fd8996760341f3e82990b36d273
child 86657 7f26e362a9f7d06f43d5e525ca5c4d9b79ccb11b
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop, unfocussed
bugs714168
milestone12.0a1
bug 714168 - make reftest-remote seems to fail on tablets because nsLocalFileUnix throws exceptions when setting file permissions on a FAT file system r=mossop,unfocussed
toolkit/mozapps/extensions/XPIProvider.jsm
--- a/toolkit/mozapps/extensions/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/XPIProvider.jsm
@@ -195,16 +195,34 @@ var gIDTest = /^(\{[0-9a-f]{8}-[0-9a-f]{
 ["LOG", "WARN", "ERROR"].forEach(function(aName) {
   this.__defineGetter__(aName, function() {
     Components.utils.import("resource://gre/modules/AddonLogging.jsm");
 
     LogManager.getLogger("addons.xpi", this);
     return this[aName];
   })
 }, this);
+  /**
+   * Sets permissions on a file
+   *
+   * @param  aFile
+   *         The file or directory to operate on.
+   * @param  aPermissions
+   *         The permisions to set
+   */
+
+function setFilePermissions(aFile, aPermissions) {
+  try {
+    aFile.permissions = aPermissions;
+  }
+  catch (e) {
+    WARN("Failed to set permissions " + aPermissions.toString(8) + " on " +
+         aFile.path, e);
+  }
+}
 
 /**
  * A safe way to install a file or the contents of a directory to a new
  * directory. The file or directory is moved or copied recursively and if
  * anything fails an attempt is made to rollback the entire operation. The
  * operation may also be rolled back to its original state after it has
  * completed by calling the rollback method.
  *
@@ -274,17 +292,17 @@ SafeInstallOperation.prototype = {
 
     // If this is only a copy operation then there is nothing else to do
     if (aCopy)
       return;
 
     // The directory should be empty by this point. If it isn't this will throw
     // and all of the operations will be rolled back
     try {
-      aDirectory.permissions = FileUtils.PERMS_DIRECTORY;
+      setPermissions(aDirectory, FileUtils.PERMS_DIRECTORY);
       aDirectory.remove(false);
     }
     catch (e) {
       ERROR("Failed to remove directory " + aDirectory.path, e);
       throw e;
     }
 
     // Note we put the directory move in after all the file moves so the
@@ -1080,17 +1098,23 @@ function extractFiles(aZipFile, aDir) {
     entries = zipReader.findEntries(null);
     while (entries.hasMore()) {
       let entryName = entries.getNext();
       let target = getTargetFile(aDir, entryName);
       if (target.exists())
         continue;
 
       zipReader.extract(entryName, target);
-      target.permissions |= FileUtils.PERMS_FILE;
+      try {
+        target.permissions |= FileUtils.PERMS_FILE;
+      }
+      catch (e) {
+        WARN("Failed to set permissions " + aPermissions.toString(8) + " on " +
+             target.path, e);
+      }
     }
   }
   finally {
     zipReader.close();
   }
 }
 
 /**
@@ -1247,34 +1271,34 @@ function cleanStagingDir(aDir, aLeafName
     if (dirEntries.nextFile)
       return;
   }
   finally {
     dirEntries.close();
   }
 
   try {
-    aDir.permissions = FileUtils.PERMS_DIRECTORY;
+    setPermissions(aDir, FileUtils.PERMS_DIRECTORY);
     aDir.remove(false);
   }
   catch (e) {
     WARN("Failed to remove staging dir", e);
     // Failing to remove the staging directory is ignorable
   }
 }
 
 /**
  * Recursively removes a directory or file fixing permissions when necessary.
  *
  * @param  aFile
  *         The nsIFile to remove
  */
 function recursiveRemove(aFile) {
-  aFile.permissions = aFile.isDirectory() ? FileUtils.PERMS_DIRECTORY
-                                          : FileUtils.PERMS_FILE;
+  setPermissions(aFile, aFile.isDirectory() ? FileUtils.PERMS_DIRECTORY
+                                            : FileUtils.PERMS_FILE);
 
   try {
     aFile.remove(true);
     return;
   }
   catch (e) {
     if (!aFile.isDirectory()) {
       ERROR("Failed to remove file " + aFile.path, e);
@@ -8071,17 +8095,21 @@ DirectoryInstallLocation.prototype = {
       }
       catch (e) {
         WARN("Failed to remove trash directory when installing " + aId, e);
       }
     }
 
     let newFile = this._directory.clone().QueryInterface(Ci.nsILocalFile);
     newFile.append(aSource.leafName);
-    newFile.lastModifiedTime = Date.now();
+    try {
+      newFile.lastModifiedTime = Date.now();
+    } catch (e)  {
+      WARN("failed to set lastModifiedTime on " + newFile.path, e);
+    }
     this._FileToIDMap[newFile.path] = aId;
     this._IDToFileMap[aId] = newFile;
 
     if (aExistingAddonID && aExistingAddonID != aId &&
         aExistingAddonID in this._IDToFileMap) {
       delete this._FileToIDMap[this._IDToFileMap[aExistingAddonID]];
       delete this._IDToFileMap[aExistingAddonID];
     }