{"action":"created","issue":{"url":"https://api.github.com/repos/atom/tree-view/issues/371","labels_url":"https://api.github.com/repos/atom/tree-view/issues/371/labels{/name}","comments_url":"https://api.github.com/repos/atom/tree-view/issues/371/comments","events_url":"https://api.github.com/repos/atom/tree-view/issues/371/events","html_url":"https://github.com/atom/tree-view/pull/371","id":57732532,"number":371,"title":"Check if entries exist before pasting them","user":{"login":"izuzak","id":38924,"avatar_url":"https://avatars.githubusercontent.com/u/38924?v=3","gravatar_id":"","url":"https://api.github.com/users/izuzak","html_url":"https://github.com/izuzak","followers_url":"https://api.github.com/users/izuzak/followers","following_url":"https://api.github.com/users/izuzak/following{/other_user}","gists_url":"https://api.github.com/users/izuzak/gists{/gist_id}","starred_url":"https://api.github.com/users/izuzak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/izuzak/subscriptions","organizations_url":"https://api.github.com/users/izuzak/orgs","repos_url":"https://api.github.com/users/izuzak/repos","events_url":"https://api.github.com/users/izuzak/events{/privacy}","received_events_url":"https://api.github.com/users/izuzak/received_events","type":"User","site_admin":true},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-15T14:47:37Z","updated_at":"2015-02-15T15:11:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/atom/tree-view/pulls/371","html_url":"https://github.com/atom/tree-view/pull/371","diff_url":"https://github.com/atom/tree-view/pull/371.diff","patch_url":"https://github.com/atom/tree-view/pull/371.patch"},"body":"Fixes https://github.com/atom/tree-view/issues/356 and a bunch of other issues merged into that one:\r\n\r\n* 93054a6 adds a failing test case for which the test output throws the exception mentioned in the issue:\r\n\r\n  ```\r\n$ apm test\r\n\r\nTreeView\r\n  file modification\r\n    tree-view:paste\r\n      when pasting entries which don't exist anymore\r\n        it skips the entry which doesn't exist\r\n          Error: ENOENT, no such file or directory '/private/var/folders/60/ft83xwb56ssf35_50_zr1kcm0000gn/T/tree-view115115-4915-scz0ax/test-dir2/test-file-doesnt-exist1.txt'\r\n            Error: ENOENT, no such file or directory '/private/var/folders/60/ft83xwb56ssf35_50_zr1kcm0000gn/T/tree-view115115-4915-scz0ax/test-dir2/test-file-doesnt-exist1.txt'\r\n            at Error (native)\r\n            at Object.fs.openSync (fs.js:503:18)\r\n            at Object.module.(anonymous function) [as openSync] (/Applications/Atom.app/Contents/Resources/atom/common/lib/asar.js:422:20)\r\n            at Object.fs.readFileSync (fs.js:355:15)\r\n            at Object.fs.readFileSync (/Applications/Atom.app/Contents/Resources/atom/common/lib/asar.js:329:27)\r\n            at TreeView.module.exports.TreeView.pasteEntries (/Users/izuzak/github/tree-view/lib/tree-view.coffee:566:42)\r\n            at space-pen-div.atom.commands.add.tree-view:paste (/Users/izuzak/github/tree-view/lib/tree-view.coffee:115:29)\r\n            at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Users/izuzak/github/atom/src/command-registry.coffee:225:27)\r\n            at CommandRegistry.handleCommandEvent (/Users/izuzak/github/atom/src/command-registry.coffee:1:1)\r\n            at CommandRegistry.module.exports.CommandRegistry.dispatch (/Users/izuzak/github/atom/src/command-registry.coffee:173:6)\r\n            at [object Object].<anonymous> (/Users/izuzak/github/tree-view/spec/tree-view-spec.coffee:1179:25)\r\n            at _fulfilled (/Users/izuzak/github/atom/node_modules/q/q.js:794:54)\r\n            at self.promiseDispatch.done (/Users/izuzak/github/atom/node_modules/q/q.js:823:30)\r\n            at Promise.promise.promiseDispatch (/Users/izuzak/github/atom/node_modules/q/q.js:756:13)\r\n            at /Users/izuzak/github/atom/node_modules/q/q.js:564:44\r\n            at flush (/Users/izuzak/github/atom/node_modules/q/q.js:110:17)\r\n            at process._tickCallback (node.js:364:11)\r\n\r\nFinished in 29.807 seconds\r\n194 tests, 700 assertions, 1 failure, 0 skipped\r\n```\r\n\r\n*  8a67618 adds a check so that entries which don't exist anymore are skipped when pasting. Running the test now completes without failures.\r\n\r\nNotes: \r\n* using `fs.existsSync` is not recommended in the [official docs](http://nodejs.org/api/fs.html#fs_fs_exists_path_callback). An alternative would be to let the code execute and catch+handle the exception. Still, I think the current solution is good enough in this case for now (and we use `fs.existsSync` in a bunch of other places).\r\n* wasn't sure how many tests would be cool for this, so added just one. The code path is the same for both files/directories (as a source and as a target) and for both copy/cut operations. Still, happy to add more tests for those variations if there's a chance this would prevent future breakage. :+1: \r\n\r\ncc @kevinsawicki for :eyes: "},"comment":{"url":"https://api.github.com/repos/atom/tree-view/issues/comments/74421068","html_url":"https://github.com/atom/tree-view/pull/371#issuecomment-74421068","issue_url":"https://api.github.com/repos/atom/tree-view/issues/371","id":74421068,"user":{"login":"thomasjo","id":3622,"avatar_url":"https://avatars.githubusercontent.com/u/3622?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasjo","html_url":"https://github.com/thomasjo","followers_url":"https://api.github.com/users/thomasjo/followers","following_url":"https://api.github.com/users/thomasjo/following{/other_user}","gists_url":"https://api.github.com/users/thomasjo/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasjo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasjo/subscriptions","organizations_url":"https://api.github.com/users/thomasjo/orgs","repos_url":"https://api.github.com/users/thomasjo/repos","events_url":"https://api.github.com/users/thomasjo/events{/privacy}","received_events_url":"https://api.github.com/users/thomasjo/received_events","type":"User","site_admin":false},"created_at":"2015-02-15T15:11:46Z","updated_at":"2015-02-15T15:11:46Z","body":"Looks good to me at least :+1: "}}