Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Directory creation error #4244

Merged
merged 10 commits into from
Jul 11, 2013
10 changes: 6 additions & 4 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ define({
"NO_MODIFICATION_ALLOWED_ERR" : "The target directory cannot be modified.",
"NO_MODIFICATION_ALLOWED_ERR_FILE" : "The permissions do not allow you to make modifications.",
"FILE_EXISTS_ERR" : "The file or directory already exists.",
"FILE" : "file",
"DIRECTORY" : "directory",

// Project error strings
"ERROR_LOADING_PROJECT" : "Error loading project",
Expand All @@ -55,11 +57,11 @@ define({
"ERROR_RENAMING_FILE" : "An error occurred when trying to rename the file <span class='dialog-filename'>{0}</span>. {1}",
"ERROR_DELETING_FILE_TITLE" : "Error deleting file",
"ERROR_DELETING_FILE" : "An error occurred when trying to delete the file <span class='dialog-filename'>{0}</span>. {1}",
"INVALID_FILENAME_TITLE" : "Invalid file name",
"INVALID_FILENAME_TITLE" : "Invalid {0} name",
"INVALID_FILENAME_MESSAGE" : "Filenames cannot contain the following characters: /?*:;{}<>\\| or use any system reserved words.",
"FILE_ALREADY_EXISTS" : "The file <span class='dialog-filename'>{0}</span> already exists.",
"ERROR_CREATING_FILE_TITLE" : "Error creating file",
"ERROR_CREATING_FILE" : "An error occurred when trying to create the file <span class='dialog-filename'>{0}</span>. {1}",
"FILE_ALREADY_EXISTS" : "The {0} <span class='dialog-filename'>{1}</span> already exists.",
"ERROR_CREATING_FILE_TITLE" : "Error creating {0}",
"ERROR_CREATING_FILE" : "An error occurred when trying to create the {0} <span class='dialog-filename'>{1}</span>. {2}",

// Application error strings
"ERROR_IN_BROWSER_TITLE" : "Oops! {APP_NAME} doesn't run in browsers yet.",
Expand Down
18 changes: 7 additions & 11 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1227,15 +1227,14 @@ define(function (require, exports, module) {
};

var errorCallback = function (error) {
var entryType = isFolder ? Strings.DIRECTORY : Strings.FILE;
if ((error.name === NativeFileError.PATH_EXISTS_ERR) ||
(error.name === NativeFileError.TYPE_MISMATCH_ERR)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost. I went back to the original bug to test and found some more issues not mentioned.

If you create a file with a name foo, the try to create a directory of the same name, you get "The directory foo already exists" instead of "The file foo already exists"...and vice versa.

You can split the if here with an else if branch to handle TYPE_MISMATCH_ERR separate from PATH_EXISTS_ERROR, that should fix it.

Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_ERROR,
Strings.INVALID_FILENAME_TITLE,
StringUtils.format(
Strings.FILE_ALREADY_EXISTS,
StringUtils.breakableUrl(data.rslt.name)
)
StringUtils.format(Strings.INVALID_FILENAME_TITLE, entryType),
StringUtils.format(Strings.FILE_ALREADY_EXISTS, entryType,
StringUtils.breakableUrl(data.rslt.name))
);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this else branch there is another error dialog that always display "File" in the strings as the code fixed. Maybe this could be fixed here too.

var errString = error.name === NativeFileError.NO_MODIFICATION_ALLOWED_ERR ?
Expand All @@ -1244,12 +1243,9 @@ define(function (require, exports, module) {

Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_ERROR,
Strings.ERROR_CREATING_FILE_TITLE,
StringUtils.format(
Strings.ERROR_CREATING_FILE,
StringUtils.breakableUrl(data.rslt.name),
errString
)
StringUtils.format(Strings.ERROR_CREATING_FILE_TITLE, entryType),
StringUtils.format(Strings.ERROR_CREATING_FILE, entryType,
Strings.breakableUrl(data.rslt.name), errString)
);
}

Expand Down