Bug 1177541 - Remove warning if file is not found during deferred open. r=mcmanus
authorEric Rahm <erahm@mozilla.com>
Tue, 30 Jun 2015 09:33:37 -0700
changeset 250719 76b550ed61659bd53264e4c0a280ec1a4b54677d
parent 250718 e93fd5c792352f085ab32e81f6bc2fa55c003fb3
child 250720 6b9d80a126e59bf727a0856ab58070fc40c24cb3
push idunknown
push userunknown
push dateunknown
reviewersmcmanus
bugs1177541
milestone42.0a1
Bug 1177541 - Remove warning if file is not found during deferred open. r=mcmanus When doing a deferred open we should not emit a warning if the file is not found. The proper return code is still returned.
netwerk/base/nsFileStreams.cpp
--- a/netwerk/base/nsFileStreams.cpp
+++ b/netwerk/base/nsFileStreams.cpp
@@ -197,16 +197,21 @@ nsFileStreamBase::Available(uint64_t* aR
     *aResult = (uint64_t)avail;
     return NS_OK;
 }
 
 nsresult
 nsFileStreamBase::Read(char* aBuf, uint32_t aCount, uint32_t* aResult)
 {
     nsresult rv = DoPendingOpen();
+    if (rv == NS_ERROR_FILE_NOT_FOUND) {
+      // Don't warn if this is just a deferred file not found.
+      return rv;
+    }
+
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (!mFD) {
         *aResult = 0;
         return NS_OK;
     }
 
     int32_t bytesRead = PR_Read(mFD, aBuf, aCount);
@@ -484,16 +489,21 @@ nsFileInputStream::Close()
     }
     return rv;
 }
 
 NS_IMETHODIMP
 nsFileInputStream::Read(char* aBuf, uint32_t aCount, uint32_t* _retval)
 {
     nsresult rv = nsFileStreamBase::Read(aBuf, aCount, _retval);
+    if (rv == NS_ERROR_FILE_NOT_FOUND) {
+      // Don't warn if this is a deffered file not found.
+      return rv;
+    }
+
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Check if we're at the end of file and need to close
     if (mBehaviorFlags & CLOSE_ON_EOF && *_retval == 0) {
         Close();
     }
 
     return NS_OK;