Bug 468471 - "Move Spotlight metadata out of the profile dir so results get shown" - Decouple profile dir from search path logic. [r=bugzilla,sid0]

This commit is contained in:
David Humphrey 2009-03-13 21:48:24 +00:00
Родитель c0202bb30b
Коммит b7507f5f4b
3 изменённых файлов: 35 добавлений и 7 удалений

Просмотреть файл

@ -56,6 +56,28 @@ let SearchIntegration =
/// The Spotlight pref base
_prefBase: "mail.spotlight.",
/// The user's profile dir, which we'll cache and use a lot for path clean-up
get _profileDir()
{
delete this._profileDir;
return this._profileDir = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("ProfD", Ci.nsIFile);
}
/// Spotlight won't index files in the profile dir, but will use ~/Library/Caches/Metadata
_getSearchPathForFolder: function spotlight_get_search_path(aFolder)
{
// Swap the metadata dir for the profile dir prefix in the folder's path
let folderPath = aFolder.filePath.path;
let fixedPath = folderPath.replace(this._profileDir.path,
"~/Library/Caches/Metadata/Thunderbird");
let searchPath = Cc["@mozilla.org/file/local;1"]
.createInstance(Ci.nsILocalFile);
searchPath.initWithPath(fixedPath);
return searchPath;
},
_init: function spotlight_init()
{
this._initLogging();

Просмотреть файл

@ -161,6 +161,12 @@ let SearchIntegration =
return true;
},
/// Use the folder's path (i.e., in profile dir) as is
_getSearchPathForFolder: function winsearch_get_search_path(aFolder)
{
return aFolder.filePath;
},
_init: function winsearch_init()
{
this._initLogging();

Просмотреть файл

@ -434,7 +434,7 @@ let SearchSupport =
aSrcMsgs.queryElementAt(i, Ci.nsIMsgDBHdr));
if (srcFile && srcFile.exists())
{
let destFile = aDestFolder.filePath;
let destFile = SearchIntegration._getSearchPathForFolder(aDestFolder);
destFile.leafName = destFile.leafName + ".mozmsgs";
if (!destFile.exists())
{
@ -460,7 +460,7 @@ let SearchSupport =
{
SearchIntegration._log.info("in folderDeleted, folder name = " +
aFolder.prettiestName);
let srcFile = aFolder.filePath;
let srcFile = SearchIntegration._getSearchPathForFolder(aFolder);
srcFile.leafName = srcFile.leafName + ".mozmsgs";
if (srcFile.exists())
srcFile.remove(true);
@ -475,8 +475,8 @@ let SearchSupport =
if (!aMove && !this.enabled)
return;
let srcFile = aSrcFolder.filePath;
let destFile = aDestFolder.filePath;
let srcFile = SearchIntegration._getSearchPathForFolder(aSrcFolder);
let destFile = SearchIntegration._getSearchPathForFolder(aDestFolder);
srcFile.leafName = srcFile.leafName + ".mozmsgs";
destFile.leafName += ".sbd";
SearchIntegration._log.debug("src file path = " + srcFile.path);
@ -496,7 +496,7 @@ let SearchSupport =
SearchIntegration._log.info("in folderRenamed, aOrigFolder = " +
aOrigFolder.prettiestName +
", aNewFolder = " + aNewFolder.prettiestName);
let srcFile = aOrigFolder.filePath;
let srcFile = SearchIntegration._getSearchPathForFolder(aOrigFolder);
srcFile.leafName = srcFile.leafName + ".mozmsgs";
let destName = aNewFolder.name + ".mozmsgs";
SearchIntegration._log.debug("src file path = " + srcFile.path);
@ -534,7 +534,7 @@ let SearchSupport =
{
let messageId = encodeURIComponent(msgHdr.messageId);
this._log.debug("encoded message id = " + messageId);
let file = folder.filePath;
let file = this._getSearchPathForFolder(folder);
file.leafName = file.leafName + ".mozmsgs";
file.appendRelativePath(messageId + this._fileExt);
this._log.debug("getting support file path = " + file.path);
@ -602,7 +602,7 @@ let SearchSupport =
let messageId = encodeURIComponent(msgHdr.messageId);
SearchIntegration._log.info("generating support file, id = " +
messageId);
let file = folder.filePath;
let file = SearchIntegration._getSearchPathForFolder(folder);
file.leafName = file.leafName + ".mozmsgs";
SearchIntegration._log.debug("file leafname = " + file.leafName);