{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/23723210","id":23723210,"diff_hunk":"@@ -513,13 +516,42 @@ private[spark] object Utils extends Logging {\n       Files.move(sourceFile, destFile)\n     } else {\n       logInfo(s\"Copying ${sourceFile.getAbsolutePath} to ${destFile.getAbsolutePath}\")\n-      Files.copy(sourceFile, destFile)\n+      copyRecursive(sourceFile, destFile)\n+    }\n+  }\n+\n+  private def filesEqualRecursive(file1: File, file2: File): Boolean = {\n+    if (file1.isDirectory && file2.isDirectory) {\n+      val subfiles1 = file1.listFiles()\n+      val subfiles2 = file2.listFiles()\n+      if (subfiles1.size != subfiles2.size) {\n+        return false\n+      }\n+      subfiles1.sortBy(_.getName).zip(subfiles2.sortBy(_.getName)).dropWhile {\n+        case (f1, f2) => filesEqualRecursive(f1, f2)\n+      }.isEmpty\n+    } else if (file1.isFile && file2.isFile) {\n+      Files.equal(file1, file2)\n+    } else {\n+      false\n+    }\n+  }\n+\n+  private def copyRecursive(source: File, dest: File): Unit = {\n+    if (source.isDirectory) {\n+      dest.mkdir()","path":"core/src/main/scala/org/apache/spark/util/Utils.scala","position":71,"original_position":71,"commit_id":"17757c61db4400a36506398101c9c48f7e57bd23","original_commit_id":"17757c61db4400a36506398101c9c48f7e57bd23","user":{"login":"vanzin","id":1694083,"avatar_url":"https://avatars.githubusercontent.com/u/1694083?v=3","gravatar_id":"","url":"https://api.github.com/users/vanzin","html_url":"https://github.com/vanzin","followers_url":"https://api.github.com/users/vanzin/followers","following_url":"https://api.github.com/users/vanzin/following{/other_user}","gists_url":"https://api.github.com/users/vanzin/gists{/gist_id}","starred_url":"https://api.github.com/users/vanzin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanzin/subscriptions","organizations_url":"https://api.github.com/users/vanzin/orgs","repos_url":"https://api.github.com/users/vanzin/repos","events_url":"https://api.github.com/users/vanzin/events{/privacy}","received_events_url":"https://api.github.com/users/vanzin/received_events","type":"User","site_admin":false},"body":"This can fail; check return value and throw exception in that case?","created_at":"2015-01-28T21:02:29Z","updated_at":"2015-01-28T21:02:29Z","html_url":"https://github.com/apache/spark/pull/3670#discussion_r23723210","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/3670","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/23723210"},"html":{"href":"https://github.com/apache/spark/pull/3670#discussion_r23723210"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/3670"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/3670","id":25868790,"html_url":"https://github.com/apache/spark/pull/3670","diff_url":"https://github.com/apache/spark/pull/3670.diff","patch_url":"https://github.com/apache/spark/pull/3670.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/3670","number":3670,"state":"open","locked":false,"title":"SPARK-4687. [WIP] Add an addDirectory API","user":{"login":"sryza","id":654855,"avatar_url":"https://avatars.githubusercontent.com/u/654855?v=3","gravatar_id":"","url":"https://api.github.com/users/sryza","html_url":"https://github.com/sryza","followers_url":"https://api.github.com/users/sryza/followers","following_url":"https://api.github.com/users/sryza/following{/other_user}","gists_url":"https://api.github.com/users/sryza/gists{/gist_id}","starred_url":"https://api.github.com/users/sryza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sryza/subscriptions","organizations_url":"https://api.github.com/users/sryza/orgs","repos_url":"https://api.github.com/users/sryza/repos","events_url":"https://api.github.com/users/sryza/events{/privacy}","received_events_url":"https://api.github.com/users/sryza/received_events","type":"User","site_admin":false},"body":"This adds an addDirectory API to satisfy Hive's needs.  It only allows specifying HDFS dirs that will be copied down on every executor.\r\n\r\nThere are a couple outstanding questions.\r\n* Should we allow specifying local dirs as well?  The best way to do this would probably be to archive them.  The drawback is that it would require a fair bit of code that I don't know of any current use cases for.\r\n* The addFiles implementation has a caching component that I don't entirely understand.  What events are we caching between?  AFAICT it's users calling addFile on the same file in the same app at different times?  Do we want/need to add something similar for addDirectory.\r\n*  The addFiles implementation will check to see if an added file already exists and has the same contents.  I imagine we want the same behavior, so planning to add this unless people think otherwise.\r\n\r\nI plan to add some tests if people are OK with the approach.","created_at":"2014-12-11T00:50:27Z","updated_at":"2015-01-28T21:02:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"99800aebe36e0014ce00ead8d67546678f47a146","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/3670/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/3670/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apache/spark/issues/3670/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/17757c61db4400a36506398101c9c48f7e57bd23","head":{"label":"sryza:sandy-spark-4687","ref":"sandy-spark-4687","sha":"17757c61db4400a36506398101c9c48f7e57bd23","user":{"login":"sryza","id":654855,"avatar_url":"https://avatars.githubusercontent.com/u/654855?v=3","gravatar_id":"","url":"https://api.github.com/users/sryza","html_url":"https://github.com/sryza","followers_url":"https://api.github.com/users/sryza/followers","following_url":"https://api.github.com/users/sryza/following{/other_user}","gists_url":"https://api.github.com/users/sryza/gists{/gist_id}","starred_url":"https://api.github.com/users/sryza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sryza/subscriptions","organizations_url":"https://api.github.com/users/sryza/orgs","repos_url":"https://api.github.com/users/sryza/repos","events_url":"https://api.github.com/users/sryza/events{/privacy}","received_events_url":"https://api.github.com/users/sryza/received_events","type":"User","site_admin":false},"repo":{"id":17230980,"name":"spark","full_name":"sryza/spark","owner":{"login":"sryza","id":654855,"avatar_url":"https://avatars.githubusercontent.com/u/654855?v=3","gravatar_id":"","url":"https://api.github.com/users/sryza","html_url":"https://github.com/sryza","followers_url":"https://api.github.com/users/sryza/followers","following_url":"https://api.github.com/users/sryza/following{/other_user}","gists_url":"https://api.github.com/users/sryza/gists{/gist_id}","starred_url":"https://api.github.com/users/sryza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sryza/subscriptions","organizations_url":"https://api.github.com/users/sryza/orgs","repos_url":"https://api.github.com/users/sryza/repos","events_url":"https://api.github.com/users/sryza/events{/privacy}","received_events_url":"https://api.github.com/users/sryza/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sryza/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/sryza/spark","forks_url":"https://api.github.com/repos/sryza/spark/forks","keys_url":"https://api.github.com/repos/sryza/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sryza/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sryza/spark/teams","hooks_url":"https://api.github.com/repos/sryza/spark/hooks","issue_events_url":"https://api.github.com/repos/sryza/spark/issues/events{/number}","events_url":"https://api.github.com/repos/sryza/spark/events","assignees_url":"https://api.github.com/repos/sryza/spark/assignees{/user}","branches_url":"https://api.github.com/repos/sryza/spark/branches{/branch}","tags_url":"https://api.github.com/repos/sryza/spark/tags","blobs_url":"https://api.github.com/repos/sryza/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sryza/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sryza/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/sryza/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sryza/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/sryza/spark/languages","stargazers_url":"https://api.github.com/repos/sryza/spark/stargazers","contributors_url":"https://api.github.com/repos/sryza/spark/contributors","subscribers_url":"https://api.github.com/repos/sryza/spark/subscribers","subscription_url":"https://api.github.com/repos/sryza/spark/subscription","commits_url":"https://api.github.com/repos/sryza/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/sryza/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/sryza/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/sryza/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/sryza/spark/contents/{+path}","compare_url":"https://api.github.com/repos/sryza/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sryza/spark/merges","archive_url":"https://api.github.com/repos/sryza/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sryza/spark/downloads","issues_url":"https://api.github.com/repos/sryza/spark/issues{/number}","pulls_url":"https://api.github.com/repos/sryza/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/sryza/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/sryza/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sryza/spark/labels{/name}","releases_url":"https://api.github.com/repos/sryza/spark/releases{/id}","created_at":"2014-02-27T00:28:05Z","updated_at":"2014-06-25T08:18:09Z","pushed_at":"2015-01-28T19:45:20Z","git_url":"git://github.com/sryza/spark.git","ssh_url":"git@github.com:sryza/spark.git","clone_url":"https://github.com/sryza/spark.git","svn_url":"https://github.com/sryza/spark","homepage":null,"size":86760,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"453d7999b88be87bda30d9e73038eb484ee063bd","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-01-28T20:56:37Z","pushed_at":"2015-01-28T20:56:36Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":1164388,"stargazers_count":2686,"watchers_count":2686,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2367,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":326,"forks":2367,"open_issues":326,"watchers":2686,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/3670"},"html":{"href":"https://github.com/apache/spark/pull/3670"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/3670"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/3670/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/3670/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/3670/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/17757c61db4400a36506398101c9c48f7e57bd23"}}}}