Skip to content

Commit 2de5d93

Browse files
committed
More fixes
1 parent 63fa042 commit 2de5d93

File tree

4 files changed

+78
-42
lines changed

4 files changed

+78
-42
lines changed

locales/en-US/editor.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ ERROR_PROJECT_SIZE_EXCEEDED=The total size of the files in your project has exce
2626

2727
# File Open/Save Error strings
2828

29-
FILE_EXISTS_HEADER=The file already exists.
3029
# The {0} here will be replaced by an actual error message
3130
OPEN_DIALOG_ERROR=An error occurred when showing the open file dialog. (error {0})
3231
# {0} will be replaced with a filename and {1} will be replaced by an error message

src/filesystem/impls/filer/lib/LegacyFileImport.js

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,7 @@ define(function (require, exports, module) {
5757
return Content.isImage(Path.extname(filename)) || encoding === "utf8";
5858
}
5959

60-
function handleRegularFile(deferred, file, filename, buffer, encoding) {
61-
// Don't write thing like .DS_Store, thumbs.db, etc.
62-
if(ArchiveUtils.skipFile(filename)) {
63-
deferred.resolve();
64-
return;
65-
}
66-
60+
function saveFile(deferred, file, filename, buffer, encoding) {
6761
file.write(buffer, {encoding: encoding}, function(err) {
6862
if (err) {
6963
errorList.push({path: filename, error: "unable to write file: " + err.message || ""});
@@ -80,6 +74,50 @@ define(function (require, exports, module) {
8074
});
8175
}
8276

77+
function handleRegularFile(deferred, file, filename, buffer, encoding) {
78+
// Don't write thing like .DS_Store, thumbs.db, etc.
79+
if(ArchiveUtils.skipFile(filename)) {
80+
deferred.resolve();
81+
return;
82+
}
83+
84+
fs.exists(filename, function(doesExist) {
85+
if (!doesExist) {
86+
// File doesn't exist. Save without prompt
87+
saveFile(deferred, file, filename, buffer, encoding);
88+
return;
89+
}
90+
91+
// File exists. Prompt user for action
92+
Dialogs.showModalDialog(
93+
DefaultDialogs.DIALOG_ID_INFO,
94+
Strings.FILE_EXISTS_HEADER,
95+
StringUtils.format(Strings.DND_FILE_REPLACE, FileUtils.getBaseName(filename)),
96+
[{
97+
className : Dialogs.DIALOG_BTN_CLASS_NORMAL,
98+
id : Dialogs.DIALOG_BTN_CANCEL,
99+
text : Strings.CANCEL
100+
},
101+
{
102+
className : Dialogs.DIALOG_BTN_CLASS_NORMAL,
103+
id : Dialogs.DIALOG_BTN_IMPORT,
104+
text : Strings.USE_IMPORTED
105+
},
106+
{
107+
className : Dialogs.DIALOG_BTN_CLASS_PRIMARY,
108+
id : Dialogs.DIALOG_BTN_OK,
109+
text : Strings.KEEP_EXISTING
110+
}]
111+
)
112+
.done(function(id) {
113+
if (id === Dialogs.DIALOG_BTN_IMPORT) {
114+
// Override file per user's request
115+
saveFile(deferred, file, filename, buffer, encoding);
116+
}
117+
});
118+
});
119+
}
120+
83121
function handleZipFile(deferred, file, filename, buffer, encoding) {
84122
var basename = Path.basename(filename);
85123

src/filesystem/impls/filer/lib/WebKitFileImport.js

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -145,42 +145,41 @@ define(function (require, exports, module) {
145145

146146
function handleRegularFile(deferred, file, filename, buffer, encoding) {
147147
fs.exists(filename, function(doesExist) {
148-
if (doesExist) {
149-
console.log("File: ", filename, " already exists!");
150-
151-
// File exists. Prompt user for action
152-
Dialogs.showModalDialog(
153-
DefaultDialogs.DIALOG_ID_INFO,
154-
Strings.FILE_EXISTS_HEADER,
155-
StringUtils.format(Strings.DND_FILE_REPLACE, FileUtils.getBaseName(filename)),
156-
[
157-
{
158-
className : Dialogs.DIALOG_BTN_CLASS_NORMAL,
159-
id : Dialogs.DIALOG_BTN_CANCEL,
160-
text : Strings.CANCEL
161-
},
162-
{
163-
className : Dialogs.DIALOG_BTN_CLASS_NORMAL,
164-
id : Dialogs.DIALOG_BTN_IMPORT,
165-
text : Strings.USE_IMPORTED
166-
},
167-
{
168-
className : Dialogs.DIALOG_BTN_CLASS_PRIMARY,
169-
id : Dialogs.DIALOG_BTN_OK,
170-
text : Strings.KEEP_EXISTING
171-
}
172-
]
173-
)
174-
.done(function(id) {
175-
if (id === Dialogs.DIALOG_BTN_IMPORT) {
176-
// Override file per user's request
177-
saveFile(deferred, file, filename, buffer, encoding);
178-
}
179-
});
180-
} else {
148+
if (!doesExist) {
181149
// File doesn't exist. Save without prompt
182150
saveFile(deferred, file, filename, buffer, encoding);
151+
return;
183152
}
153+
154+
// File exists. Prompt user for action
155+
Dialogs.showModalDialog(
156+
DefaultDialogs.DIALOG_ID_INFO,
157+
Strings.FILE_EXISTS_HEADER,
158+
StringUtils.format(Strings.DND_FILE_REPLACE, FileUtils.getBaseName(filename)),
159+
[
160+
{
161+
className : Dialogs.DIALOG_BTN_CLASS_NORMAL,
162+
id : Dialogs.DIALOG_BTN_CANCEL,
163+
text : Strings.CANCEL
164+
},
165+
{
166+
className : Dialogs.DIALOG_BTN_CLASS_NORMAL,
167+
id : Dialogs.DIALOG_BTN_IMPORT,
168+
text : Strings.USE_IMPORTED
169+
},
170+
{
171+
className : Dialogs.DIALOG_BTN_CLASS_PRIMARY,
172+
id : Dialogs.DIALOG_BTN_OK,
173+
text : Strings.KEEP_EXISTING
174+
}
175+
]
176+
)
177+
.done(function(id) {
178+
if (id === Dialogs.DIALOG_BTN_IMPORT) {
179+
// Override file per user's request
180+
saveFile(deferred, file, filename, buffer, encoding);
181+
}
182+
});
184183
});
185184
}
186185

src/utils/DragAndDrop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ define(function (require, exports, module) {
141141

142142
return Async.doInParallel(paths, function (path, idx) {
143143
var result = new $.Deferred();
144+
144145
// Only open files.
145146
FileSystem.resolve(path, function (err, item) {
146147
if (!err && item.isFile) {
@@ -182,7 +183,6 @@ define(function (require, exports, module) {
182183
return result.promise();
183184
}, false)
184185
.fail(function () {
185-
console.log("fail");
186186
function errorToString(err) {
187187
if (err === ERR_MULTIPLE_ITEMS_WITH_DIR) {
188188
return Strings.ERROR_MIXED_DRAGDROP;

0 commit comments

Comments
 (0)