From 24036897e7d4a1f833bf006073e4cda7c49b3763 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Wed, 25 Jan 2012 03:24:52 -0500 Subject: [PATCH] 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 | 40 ++++++++++++++++++---- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/toolkit/mozapps/extensions/XPIProvider.jsm b/toolkit/mozapps/extensions/XPIProvider.jsm index 517f8a68855..cad02f012af 100644 --- a/toolkit/mozapps/extensions/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/XPIProvider.jsm @@ -200,6 +200,24 @@ var gIDTest = /^(\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\ 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 @@ -279,7 +297,7 @@ SafeInstallOperation.prototype = { // 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) { @@ -1085,7 +1103,13 @@ function extractFiles(aZipFile, aDir) { 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 { @@ -1252,7 +1276,7 @@ function cleanStagingDir(aDir, aLeafNames) { } try { - aDir.permissions = FileUtils.PERMS_DIRECTORY; + setPermissions(aDir, FileUtils.PERMS_DIRECTORY); aDir.remove(false); } catch (e) { @@ -1268,8 +1292,8 @@ function cleanStagingDir(aDir, aLeafNames) { * 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); @@ -8076,7 +8100,11 @@ DirectoryInstallLocation.prototype = { 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;