Bug 791816 - Use a different error string when we may overwrite a file location. r=sicking

This commit is contained in:
Doug Turner 2012-10-13 08:20:14 -07:00
parent 96917e737c
commit 8660aa99c4
3 changed files with 19 additions and 0 deletions

View File

@ -248,6 +248,14 @@ DeviceStorageRequestParent::WriteFileEvent::CancelableRun()
return NS_OK;
}
bool check = false;
mFile->mFile->Exists(&check);
if (check) {
nsCOMPtr<PostErrorEvent> event = new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_EXISTS);
NS_DispatchToMainThread(event);
return NS_OK;
}
nsresult rv = mFile->Write(mInputStream);
if (NS_FAILED(rv)) {

View File

@ -1285,6 +1285,16 @@ public:
nsCOMPtr<nsIInputStream> stream;
mBlob->GetInternalStream(getter_AddRefs(stream));
bool check = false;
mFile->mFile->Exists(&check);
if (check) {
nsCOMPtr<PostErrorEvent> event = new PostErrorEvent(mRequest,
POST_ERROR_EVENT_FILE_EXISTS,
mFile);
NS_DispatchToMainThread(event);
return NS_OK;
}
nsresult rv = mFile->Write(stream);
if (NS_FAILED(rv)) {

View File

@ -32,6 +32,7 @@ class nsPIDOMWindow;
#include "DeviceStorageRequestChild.h"
#define POST_ERROR_EVENT_FILE_EXISTS "File already exists"
#define POST_ERROR_EVENT_FILE_DOES_NOT_EXIST "File location doesn't exists"
#define POST_ERROR_EVENT_FILE_NOT_ENUMERABLE "File location is not enumerable"
#define POST_ERROR_EVENT_PERMISSION_DENIED "Permission Denied"