From 7c41907a7d3a1892907c09ff9d9a58f3d013d767 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Sat, 9 Mar 2013 14:55:17 -0800 Subject: [PATCH] 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. --- src/packages/tree-view/lib/tree-view.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/packages/tree-view/lib/tree-view.coffee b/src/packages/tree-view/lib/tree-view.coffee index bf1df2b2e..fb3da5783 100644 --- a/src/packages/tree-view/lib/tree-view.coffee +++ b/src/packages/tree-view/lib/tree-view.coffee @@ -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)