CopyToNative return value check (one indirect) draft
authorISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
Sat, 09 Nov 2019 11:11:57 +0900
changeset 81093 e18d69461edcddb1b3653838eee5c2baf8ec29a4
parent 81092 c2490a04ab6c2f5d94da4421e9ad5b9bdfdb00ea
child 81094 b403fb968812671266c382bb549689a0e7b0118c
push id9745
push userishikawa@yk.rim.or.jp
push dateSat, 09 Nov 2019 02:12:14 +0000
treeherdertry-comm-central@f62e5475decc [default view] [failures only]
CopyToNative return value check (one indirect)
mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/local/src/nsLocalMailFolder.cpp
--- a/mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp
+++ b/mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp
@@ -224,19 +224,22 @@ nsresult nsMsgMailViewList::LoadMailView
     nsCOMPtr<nsIFile> profileDir;
     rv = mailSession->GetDataFilesDir("messenger",
                                       getter_AddRefs(defaultMessagesFile));
     rv = defaultMessagesFile->AppendNative(nsDependentCString("mailViews.dat"));
 
     // get the profile directory
     rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
                                 getter_AddRefs(profileDir));
+    NS_ENSURE_SUCCESS(rv, rv);  // if we fail this, we are totally confused.
+    // xxx we probably need visual feedback when error occurs.
 
     // now copy the file over to the profile directory
-    defaultMessagesFile->CopyToNative(profileDir, EmptyCString());
+    rv = defaultMessagesFile->CopyToNative(profileDir, EmptyCString());
+    NS_ENSURE_SUCCESS(rv, rv);
   }
   // this is kind of a hack but I think it will be an effective hack. The filter
   // service already knows how to take a nsIFile and parse the contents into
   // filters which are very similar to mail views. Instead of re-writing all of
   // that dirty parsing code, let's just re-use it then convert the results into
   // a data strcuture we wish to give to our consumers.
 
   nsCOMPtr<nsIMsgFilterService> filterService =
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -1502,19 +1502,22 @@ NS_IMETHODIMP nsImapMailFolder::RenameLo
   // (ref. bug 264071)
   nsAutoCString leafname(newName);
   nsAutoCString parentName;
   // newName always in the canonical form "greatparent/parentname/leafname"
   int32_t leafpos = leafname.RFindChar('/');
   if (leafpos > 0) leafname.Cut(0, leafpos + 1);
   m_msgParser = nullptr;
   PrepareToRename();
-  CloseAndBackupFolderDB(leafname);
-
-  nsresult rv = NS_OK;
+  nsresult rv;
+  rv = CloseAndBackupFolderDB(leafname);
+  // xxx We may need UI feedback when an error occurs.
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  rv = NS_OK;
   nsCOMPtr<nsIFile> oldPathFile;
   rv = GetFilePath(getter_AddRefs(oldPathFile));
   if (NS_FAILED(rv)) return rv;
 
   nsCOMPtr<nsIFile> parentPathFile;
   rv = parent->GetFilePath(getter_AddRefs(parentPathFile));
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -290,17 +290,19 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetD
           dbFolderInfo->GetTransferInfo(getter_AddRefs(transferInfo));
         }
         dbFolderInfo = nullptr;
 
         // A backup message database might have been created earlier, for
         // example if the user requested a reindex. We'll use the earlier one if
         // we can, otherwise we'll try to backup at this point.
         if (NS_FAILED(OpenBackupMsgDatabase())) {
-          CloseAndBackupFolderDB(EmptyCString());
+          rv = CloseAndBackupFolderDB(EmptyCString());
+          // xxx we may need a UI feedback when an error occurs.
+          NS_ENSURE_SUCCESS(rv, rv);
           if (NS_FAILED(OpenBackupMsgDatabase()) && mBackupDatabase) {
             mBackupDatabase->RemoveListener(this);
             mBackupDatabase = nullptr;
           }
         } else
           mDatabase->ForceClosed();
 
         mDatabase = nullptr;