Check if path exists before moving

fs.move() no longer throws an exception if the target exists
so check for it explicitly when the dialog is confirmed.
This commit is contained in:
Kevin Sawicki 2013-03-09 14:55:17 -08:00
parent 28f89672d0
commit 7c41907a7d

View File

@ -220,6 +220,14 @@ class TreeView extends ScrollView
iconClass: 'move'
onConfirm: (newPath) =>
newPath = project.resolve(newPath)
if oldPath is newPath
dialog.close()
return
if fs.exists(newPath)
dialog.showError("Error: #{newPath} already exists. Try a different path.")
return
directoryPath = fs.directory(newPath)
try
fs.makeTree(directoryPath) unless fs.exists(directoryPath)