{"action":"created","issue":{"url":"https://api.github.com/repos/atom/atom/issues/10286","labels_url":"https://api.github.com/repos/atom/atom/issues/10286/labels{/name}","comments_url":"https://api.github.com/repos/atom/atom/issues/10286/comments","events_url":"https://api.github.com/repos/atom/atom/issues/10286/events","html_url":"https://github.com/atom/atom/issues/10286","id":124977643,"number":10286,"title":"Reindexing stuck in loop when there are symlinks to project directories","user":{"login":"piit79","id":1672473,"avatar_url":"https://avatars.githubusercontent.com/u/1672473?v=3","gravatar_id":"","url":"https://api.github.com/users/piit79","html_url":"https://github.com/piit79","followers_url":"https://api.github.com/users/piit79/followers","following_url":"https://api.github.com/users/piit79/following{/other_user}","gists_url":"https://api.github.com/users/piit79/gists{/gist_id}","starred_url":"https://api.github.com/users/piit79/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piit79/subscriptions","organizations_url":"https://api.github.com/users/piit79/orgs","repos_url":"https://api.github.com/users/piit79/repos","events_url":"https://api.github.com/users/piit79/events{/privacy}","received_events_url":"https://api.github.com/users/piit79/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/atom/atom/labels/needs-reproduction","name":"needs-reproduction","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-01-05T14:30:10Z","updated_at":"2016-01-07T09:50:34Z","closed_at":null,"body":"Symlinks in the project pointing to directories within the project cause atom to get stuck in a loop (case 1) or report duplicate search matches (case 2).\r\n\r\n### Case 1\r\n\r\nSay there are the following entries in the project:\r\n\r\n    dir1\r\n    dir1/dir2\r\n    dir1/dir2/file1\r\n    dir1/dir2/symlink1 -> ..\r\n\r\nThe `symlink1` points to the parent directory. This creates a loop in the project filesystem and causes several issues:\r\n* Atom gets stuck in a loop when reindexing the project. The reindexing will never finish\r\n* When searching for matches within the project atom will again get stuck in a loop and keep reporting matches in the same files over and over\r\n\r\n### Case 2\r\n\r\nConsider the following project entries:\r\n\r\n    dir1\r\n    dir1/dir2\r\n    dir1/dir2/test.txt\r\n    symlink1-> dir1/dir2\r\n\r\nIn this case the `symlink1` points to a project directory further down the three. As a result the file test.txt is encountered **twice** when traversing the filesystem tree and any search matches will be reported twice.\r\n\r\n### Fix\r\n\r\nI think this should be handled cleanly by checking the target of symlinks in the project. If they point to other directories within the project they should not be followed when traversing the tree during reindexing/searching."},"comment":{"url":"https://api.github.com/repos/atom/atom/issues/comments/169612879","html_url":"https://github.com/atom/atom/issues/10286#issuecomment-169612879","issue_url":"https://api.github.com/repos/atom/atom/issues/10286","id":169612879,"user":{"login":"piit79","id":1672473,"avatar_url":"https://avatars.githubusercontent.com/u/1672473?v=3","gravatar_id":"","url":"https://api.github.com/users/piit79","html_url":"https://github.com/piit79","followers_url":"https://api.github.com/users/piit79/followers","following_url":"https://api.github.com/users/piit79/following{/other_user}","gists_url":"https://api.github.com/users/piit79/gists{/gist_id}","starred_url":"https://api.github.com/users/piit79/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piit79/subscriptions","organizations_url":"https://api.github.com/users/piit79/orgs","repos_url":"https://api.github.com/users/piit79/repos","events_url":"https://api.github.com/users/piit79/events{/privacy}","received_events_url":"https://api.github.com/users/piit79/received_events","type":"User","site_admin":false},"created_at":"2016-01-07T09:50:34Z","updated_at":"2016-01-07T09:50:34Z","body":"@amytruong I just re-tested the issue again. I was wrong in saying that the reindexing will never finish - it just takes a **very** long time in my project with over 6000 files.\r\n\r\nIf you create a simple directory structure with one file and a symlink loop the issue will be nearly the same on both Linux and Windows (I don't have a Mac to test there):\r\n\r\n    a/\r\n    a/b/\r\n    a/b/test.txt\r\n    a/b/l -> ..\r\n\r\n(Link on windows created using mklink /d.)\r\n\r\nWhen using fuzzy finder, the file test.txt will be shown 10 times in gradually longer file path (b/test.txt, b/l/test.txt, b/l/l/test.txt etc.) on both Linux and Windows.\r\n\r\nWhen searching for a match in project files, atom will show repeated matches in the same file (again, in gradually longer file path as above). In this case, **Linux** shows 40 results while **Windows** show 63 results.\r\n\r\nI still think the tree should be traversed with possible loops in mind and make sure the same paths are not traversed more than once."}}