@@ -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
0 commit comments