Bug 1598865 - do not use new hidden/system files detected in mail account local storage as mail folders. r=mkmelin
This commit is contained in:
Родитель
da523e9581
Коммит
e2b7471fd9
|
@ -383,31 +383,28 @@ nsresult nsImapMailFolder::AddSubfolderWithPath(nsAString &name,
|
|||
|
||||
nsresult nsImapMailFolder::CreateSubFolders(nsIFile *path) {
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoString currentFolderNameStr; // online name
|
||||
nsAutoString currentFolderDBNameStr; // possibly munged name
|
||||
nsCOMPtr<nsIMsgFolder> child;
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
rv = GetServer(getter_AddRefs(server));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDirectoryEnumerator> children;
|
||||
rv = path->GetDirectoryEntries(getter_AddRefs(children));
|
||||
bool more = false;
|
||||
if (children) children->HasMoreElements(&more);
|
||||
nsCOMPtr<nsIDirectoryEnumerator> directoryEnumerator;
|
||||
rv = path->GetDirectoryEntries(getter_AddRefs(directoryEnumerator));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
while (more) {
|
||||
bool hasMore = false;
|
||||
while (NS_SUCCEEDED(directoryEnumerator->HasMoreElements(&hasMore)) &&
|
||||
hasMore) {
|
||||
nsCOMPtr<nsIFile> currentFolderPath;
|
||||
rv = children->GetNextFile(getter_AddRefs(currentFolderPath));
|
||||
if (NS_FAILED(rv) || !currentFolderPath) break;
|
||||
rv = children->HasMoreElements(&more);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = directoryEnumerator->GetNextFile(getter_AddRefs(currentFolderPath));
|
||||
if (NS_FAILED(rv) || !currentFolderPath) continue;
|
||||
|
||||
nsAutoString currentFolderNameStr; // online name
|
||||
nsAutoString currentFolderDBNameStr; // possibly munged name
|
||||
currentFolderPath->GetLeafName(currentFolderNameStr);
|
||||
if (nsShouldIgnoreFile(currentFolderNameStr)) continue;
|
||||
|
||||
// OK, here we need to get the online name from the folder cache if we can.
|
||||
// If we can, use that to create the sub-folder
|
||||
nsCOMPtr<nsIMsgFolderCacheElement> cacheElement;
|
||||
nsCOMPtr<nsIFile> curFolder =
|
||||
do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -421,6 +418,7 @@ nsresult nsImapMailFolder::CreateSubFolders(nsIFile *path) {
|
|||
nsAutoString utf7LeafName = currentFolderNameStr;
|
||||
|
||||
if (curFolder) {
|
||||
nsCOMPtr<nsIMsgFolderCacheElement> cacheElement;
|
||||
rv = GetFolderCacheElemFromFile(dbFile, getter_AddRefs(cacheElement));
|
||||
if (NS_SUCCEEDED(rv) && cacheElement) {
|
||||
nsCString onlineFullUtf7Name;
|
||||
|
@ -463,6 +461,7 @@ nsresult nsImapMailFolder::CreateSubFolders(nsIFile *path) {
|
|||
msfFilePath->SetLeafName(currentFolderDBNameStr);
|
||||
}
|
||||
// use the utf7 name as the uri for the folder.
|
||||
nsCOMPtr<nsIMsgFolder> child;
|
||||
AddSubfolderWithPath(utf7LeafName, msfFilePath, getter_AddRefs(child));
|
||||
if (child) {
|
||||
// use the unicode name as the "pretty" name. Set it so it won't be
|
||||
|
|
|
@ -947,8 +947,10 @@ nsresult nsMsgBrkMBoxStore::AddSubFolders(nsIMsgFolder *parent,
|
|||
while (NS_SUCCEEDED(directoryEnumerator->HasMoreElements(&hasMore)) &&
|
||||
hasMore) {
|
||||
nsCOMPtr<nsIFile> currentFile;
|
||||
directoryEnumerator->GetNextFile(getter_AddRefs(currentFile));
|
||||
if (currentFile) currentDirEntries.AppendObject(currentFile);
|
||||
rv = directoryEnumerator->GetNextFile(getter_AddRefs(currentFile));
|
||||
if (NS_SUCCEEDED(rv) && currentFile) {
|
||||
currentDirEntries.AppendObject(currentFile);
|
||||
}
|
||||
}
|
||||
|
||||
// add the folders
|
||||
|
@ -960,7 +962,7 @@ nsresult nsMsgBrkMBoxStore::AddSubFolders(nsIMsgFolder *parent,
|
|||
currentFile->GetLeafName(leafName);
|
||||
// here we should handle the case where the current file is a .sbd directory
|
||||
// w/o a matching folder file, or a directory w/o the name .sbd
|
||||
if (nsShouldIgnoreFile(leafName)) continue;
|
||||
if (nsShouldIgnoreFile(leafName, currentFile)) continue;
|
||||
|
||||
nsCOMPtr<nsIMsgFolder> child;
|
||||
rv = parent->AddSubfolder(leafName, getter_AddRefs(child));
|
||||
|
|
|
@ -21,7 +21,7 @@ nsresult nsMsgLocalStoreUtils::AddDirectorySeparator(nsIFile *path) {
|
|||
return path->SetLeafName(leafName);
|
||||
}
|
||||
|
||||
bool nsMsgLocalStoreUtils::nsShouldIgnoreFile(nsAString &name) {
|
||||
bool nsMsgLocalStoreUtils::nsShouldIgnoreFile(nsAString &name, nsIFile *path) {
|
||||
if (name.IsEmpty()) return true;
|
||||
|
||||
char16_t firstChar = name.First();
|
||||
|
@ -54,6 +54,14 @@ bool nsMsgLocalStoreUtils::nsShouldIgnoreFile(nsAString &name) {
|
|||
StringBeginsWith(name, NS_LITERAL_STRING("feeditems_error")))
|
||||
return true;
|
||||
|
||||
// Ignore hidden and other special system files.
|
||||
bool specialFile = false;
|
||||
path->IsHidden(&specialFile);
|
||||
if (specialFile) return true;
|
||||
specialFile = false;
|
||||
path->IsSpecial(&specialFile);
|
||||
if (specialFile) return true;
|
||||
|
||||
// The .mozmsgs dir is for spotlight support
|
||||
return (StringEndsWith(name, NS_LITERAL_STRING(".mozmsgs")) ||
|
||||
StringEndsWith(name, NS_LITERAL_STRING(FOLDER_SUFFIX)) ||
|
||||
|
|
|
@ -26,7 +26,7 @@ class nsMsgLocalStoreUtils {
|
|||
nsMsgLocalStoreUtils();
|
||||
|
||||
static nsresult AddDirectorySeparator(nsIFile *path);
|
||||
static bool nsShouldIgnoreFile(nsAString &name);
|
||||
static bool nsShouldIgnoreFile(nsAString &name, nsIFile *path);
|
||||
static void ChangeKeywordsHelper(nsIMsgDBHdr *message, uint64_t desiredOffset,
|
||||
nsLineBuffer<char> *lineBuffer,
|
||||
nsTArray<nsCString> &keywordArray, bool aAdd,
|
||||
|
|
|
@ -94,7 +94,7 @@ nsresult nsMsgMaildirStore::AddSubFolders(nsIMsgFolder *parent, nsIFile *path,
|
|||
currentFile->IsDirectory(&isDirectory);
|
||||
// Make sure this really is a mail folder dir (i.e., a directory that
|
||||
// contains cur and tmp sub-dirs, and not a .sbd or .mozmsgs dir).
|
||||
if (isDirectory && !nsShouldIgnoreFile(leafName))
|
||||
if (isDirectory && !nsShouldIgnoreFile(leafName, currentFile))
|
||||
currentDirEntries.AppendObject(currentFile);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче