зеркало из https://github.com/mozilla/gecko-dev.git
Bug 330842: "ASSERT: Can't serialize: file doesn't exist!" at startup, r=mconnor
This commit is contained in:
Родитель
2016becb4a
Коммит
5f87ed855d
|
@ -1712,15 +1712,16 @@ SearchService.prototype = {
|
||||||
// Check whether aDir is the user profile dir
|
// Check whether aDir is the user profile dir
|
||||||
var isInProfile = aDir.equals(getDir(NS_APP_USER_SEARCH_DIR));
|
var isInProfile = aDir.equals(getDir(NS_APP_USER_SEARCH_DIR));
|
||||||
|
|
||||||
var files = aDir.directoryEntries;
|
var files = aDir.directoryEntries
|
||||||
|
.QueryInterface(Ci.nsIDirectoryEnumerator);
|
||||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||||
getService(Ci.nsIIOService);
|
getService(Ci.nsIIOService);
|
||||||
|
|
||||||
while (files.hasMoreElements()) {
|
while (files.hasMoreElements()) {
|
||||||
var file = files.getNext().QueryInterface(Ci.nsILocalFile);
|
var file = files.nextFile;
|
||||||
|
|
||||||
// Ignore hidden and empty files, and directories
|
// Ignore hidden and empty files, and directories
|
||||||
if (!file.isFile() || file.isHidden() || file.fileSize == 0)
|
if (file.fileSize == 0 || !file.isFile() || file.isHidden())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var fileURL = ios.newFileURI(file).QueryInterface(Ci.nsIURL);
|
var fileURL = ios.newFileURI(file).QueryInterface(Ci.nsIURL);
|
||||||
|
@ -1812,34 +1813,38 @@ SearchService.prototype = {
|
||||||
}
|
}
|
||||||
} catch (ex) { LOG("_convertSherlockFile: Error setting icon: " + ex); }
|
} catch (ex) { LOG("_convertSherlockFile: Error setting icon: " + ex); }
|
||||||
|
|
||||||
var oldFile = aEngine._file;
|
var oldSherlockFile = aEngine._file;
|
||||||
|
|
||||||
// Back up the old file
|
// Back up the old file
|
||||||
try {
|
try {
|
||||||
var backupDir = oldFile.parent;
|
var backupDir = oldSherlockFile.parent;
|
||||||
backupDir.append("searchplugins-backup");
|
backupDir.append("searchplugins-backup");
|
||||||
|
|
||||||
if (!backupDir.exists())
|
if (!backupDir.exists())
|
||||||
backupDir.create(Ci.nsIFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
|
backupDir.create(Ci.nsIFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
|
||||||
|
|
||||||
oldFile.copyTo(backupDir, null);
|
oldSherlockFile.copyTo(backupDir, null);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
// Just bail. Engines that can't be backed up won't be converted, but
|
// Just bail. Engines that can't be backed up won't be converted, but
|
||||||
// engines that aren't converted are loaded as readonly.
|
// engines that aren't converted are loaded as readonly.
|
||||||
LOG("_convertSherlockFile: Couldn't back up " + oldFile.path + ".");
|
LOG("_convertSherlockFile: Couldn't back up " + oldSherlockFile.path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename the file, but don't clobber existing files
|
// Rename the file, but don't clobber existing files
|
||||||
var newFile = oldFile.parent.clone();
|
var newXMLFile = oldSherlockFile.parent.clone();
|
||||||
newFile.append(aBaseName + "." + XML_FILE_EXT);
|
newXMLFile.append(aBaseName + "." + XML_FILE_EXT);
|
||||||
|
|
||||||
if (!newFile.exists())
|
if (newXMLFile.exists()) {
|
||||||
oldFile.moveTo(null, aBaseName + "." + XML_FILE_EXT);
|
// There is an existing file with this name, create a unique file
|
||||||
else {
|
newXMLFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
|
||||||
newFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, PERMS_FILE);
|
|
||||||
oldFile.moveTo(null, newFile.leafName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rename the .src file to .xml
|
||||||
|
oldSherlockFile.moveTo(null, newXMLFile.leafName);
|
||||||
|
|
||||||
|
aEngine._file = newXMLFile;
|
||||||
|
|
||||||
// Write the converted engine to disk
|
// Write the converted engine to disk
|
||||||
aEngine._serializeToFile();
|
aEngine._serializeToFile();
|
||||||
},
|
},
|
||||||
|
|
Загрузка…
Ссылка в новой задаче