{"action":"created","comment":{"url":"https://api.github.com/repos/ambiata/notion/pulls/comments/26809051","id":26809051,"diff_hunk":"@@ -110,6 +108,19 @@ case class LocationIO(configuration: Configuration, s3Client: AmazonS3Client) {\n       }}.as(state)\n     }\n \n+  /** read a file as a stream of bytes and compute some state value */\n+  def streamBytes[A](location: Location, empty: => A, bufferSize: Int = 4096)(f: (ReadBytes, A) => A): RIO[A] =\n+    RIO.io(empty).flatMap { s =>\n+      var state = s\n+      readUnsafe(location) { in => RIO.io {\n+        val buffer = Array.ofDim[Byte](bufferSize)\n+        var length = 0\n+        while ({ length = in.read(buffer, 0, buffer.length); length != -1 }) {\n+          state = f(ReadBytes(buffer, 0, length), state)","path":"notion-core/src/main/scala/com/ambiata/notion/core/LocationIO.scala","position":33,"original_position":33,"commit_id":"b495d1f8816d8a47f56bbad01baf04ce24747517","original_commit_id":"b495d1f8816d8a47f56bbad01baf04ce24747517","user":{"login":"markhibberd","id":22832,"avatar_url":"https://avatars.githubusercontent.com/u/22832?v=3","gravatar_id":"","url":"https://api.github.com/users/markhibberd","html_url":"https://github.com/markhibberd","followers_url":"https://api.github.com/users/markhibberd/followers","following_url":"https://api.github.com/users/markhibberd/following{/other_user}","gists_url":"https://api.github.com/users/markhibberd/gists{/gist_id}","starred_url":"https://api.github.com/users/markhibberd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markhibberd/subscriptions","organizations_url":"https://api.github.com/users/markhibberd/orgs","repos_url":"https://api.github.com/users/markhibberd/repos","events_url":"https://api.github.com/users/markhibberd/events{/privacy}","received_events_url":"https://api.github.com/users/markhibberd/received_events","type":"User","site_admin":false},"body":"Yeh, definitely Buffer rather than allocating this everytime.","created_at":"2015-03-19T23:48:00Z","updated_at":"2015-03-19T23:48:00Z","html_url":"https://github.com/ambiata/notion/pull/60#discussion_r26809051","pull_request_url":"https://api.github.com/repos/ambiata/notion/pulls/60","_links":{"self":{"href":"https://api.github.com/repos/ambiata/notion/pulls/comments/26809051"},"html":{"href":"https://github.com/ambiata/notion/pull/60#discussion_r26809051"},"pull_request":{"href":"https://api.github.com/repos/ambiata/notion/pulls/60"}}},"pull_request":{"url":"https://api.github.com/repos/ambiata/notion/pulls/60","id":31402693,"html_url":"https://github.com/ambiata/notion/pull/60","diff_url":"https://github.com/ambiata/notion/pull/60.diff","patch_url":"https://github.com/ambiata/notion/pull/60.patch","issue_url":"https://api.github.com/repos/ambiata/notion/issues/60","number":60,"state":"open","locked":false,"title":"Compute a file sha1 based on the streaming of bytes","user":{"login":"etorreborre","id":10988,"avatar_url":"https://avatars.githubusercontent.com/u/10988?v=3","gravatar_id":"","url":"https://api.github.com/users/etorreborre","html_url":"https://github.com/etorreborre","followers_url":"https://api.github.com/users/etorreborre/followers","following_url":"https://api.github.com/users/etorreborre/following{/other_user}","gists_url":"https://api.github.com/users/etorreborre/gists{/gist_id}","starred_url":"https://api.github.com/users/etorreborre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etorreborre/subscriptions","organizations_url":"https://api.github.com/users/etorreborre/orgs","repos_url":"https://api.github.com/users/etorreborre/repos","events_url":"https://api.github.com/users/etorreborre/events{/privacy}","received_events_url":"https://api.github.com/users/etorreborre/received_events","type":"User","site_admin":false},"body":"This is a follow-up from #59 where a SHA1 was computed based on a stream of string lines which is not a robust way to compute the SHA1 of a file.","created_at":"2015-03-18T06:02:58Z","updated_at":"2015-03-19T23:48:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"406d7dff92a9b0a237b86c98b85b32ec6dad8e4b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ambiata/notion/pulls/60/commits","review_comments_url":"https://api.github.com/repos/ambiata/notion/pulls/60/comments","review_comment_url":"https://api.github.com/repos/ambiata/notion/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ambiata/notion/issues/60/comments","statuses_url":"https://api.github.com/repos/ambiata/notion/statuses/b495d1f8816d8a47f56bbad01baf04ce24747517","head":{"label":"ambiata:topic/fix-sha1","ref":"topic/fix-sha1","sha":"b495d1f8816d8a47f56bbad01baf04ce24747517","user":{"login":"ambiata","id":1691023,"avatar_url":"https://avatars.githubusercontent.com/u/1691023?v=3","gravatar_id":"","url":"https://api.github.com/users/ambiata","html_url":"https://github.com/ambiata","followers_url":"https://api.github.com/users/ambiata/followers","following_url":"https://api.github.com/users/ambiata/following{/other_user}","gists_url":"https://api.github.com/users/ambiata/gists{/gist_id}","starred_url":"https://api.github.com/users/ambiata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ambiata/subscriptions","organizations_url":"https://api.github.com/users/ambiata/orgs","repos_url":"https://api.github.com/users/ambiata/repos","events_url":"https://api.github.com/users/ambiata/events{/privacy}","received_events_url":"https://api.github.com/users/ambiata/received_events","type":"Organization","site_admin":false},"repo":{"id":25012772,"name":"notion","full_name":"ambiata/notion","owner":{"login":"ambiata","id":1691023,"avatar_url":"https://avatars.githubusercontent.com/u/1691023?v=3","gravatar_id":"","url":"https://api.github.com/users/ambiata","html_url":"https://github.com/ambiata","followers_url":"https://api.github.com/users/ambiata/followers","following_url":"https://api.github.com/users/ambiata/following{/other_user}","gists_url":"https://api.github.com/users/ambiata/gists{/gist_id}","starred_url":"https://api.github.com/users/ambiata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ambiata/subscriptions","organizations_url":"https://api.github.com/users/ambiata/orgs","repos_url":"https://api.github.com/users/ambiata/repos","events_url":"https://api.github.com/users/ambiata/events{/privacy}","received_events_url":"https://api.github.com/users/ambiata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ambiata/notion","description":"a general understanding; vague or imperfect conception or idea of something - in this case of file system like data storage abstractions","fork":false,"url":"https://api.github.com/repos/ambiata/notion","forks_url":"https://api.github.com/repos/ambiata/notion/forks","keys_url":"https://api.github.com/repos/ambiata/notion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ambiata/notion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ambiata/notion/teams","hooks_url":"https://api.github.com/repos/ambiata/notion/hooks","issue_events_url":"https://api.github.com/repos/ambiata/notion/issues/events{/number}","events_url":"https://api.github.com/repos/ambiata/notion/events","assignees_url":"https://api.github.com/repos/ambiata/notion/assignees{/user}","branches_url":"https://api.github.com/repos/ambiata/notion/branches{/branch}","tags_url":"https://api.github.com/repos/ambiata/notion/tags","blobs_url":"https://api.github.com/repos/ambiata/notion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ambiata/notion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ambiata/notion/git/refs{/sha}","trees_url":"https://api.github.com/repos/ambiata/notion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ambiata/notion/statuses/{sha}","languages_url":"https://api.github.com/repos/ambiata/notion/languages","stargazers_url":"https://api.github.com/repos/ambiata/notion/stargazers","contributors_url":"https://api.github.com/repos/ambiata/notion/contributors","subscribers_url":"https://api.github.com/repos/ambiata/notion/subscribers","subscription_url":"https://api.github.com/repos/ambiata/notion/subscription","commits_url":"https://api.github.com/repos/ambiata/notion/commits{/sha}","git_commits_url":"https://api.github.com/repos/ambiata/notion/git/commits{/sha}","comments_url":"https://api.github.com/repos/ambiata/notion/comments{/number}","issue_comment_url":"https://api.github.com/repos/ambiata/notion/issues/comments{/number}","contents_url":"https://api.github.com/repos/ambiata/notion/contents/{+path}","compare_url":"https://api.github.com/repos/ambiata/notion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ambiata/notion/merges","archive_url":"https://api.github.com/repos/ambiata/notion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ambiata/notion/downloads","issues_url":"https://api.github.com/repos/ambiata/notion/issues{/number}","pulls_url":"https://api.github.com/repos/ambiata/notion/pulls{/number}","milestones_url":"https://api.github.com/repos/ambiata/notion/milestones{/number}","notifications_url":"https://api.github.com/repos/ambiata/notion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ambiata/notion/labels{/name}","releases_url":"https://api.github.com/repos/ambiata/notion/releases{/id}","created_at":"2014-10-09T23:32:38Z","updated_at":"2015-03-18T00:39:38Z","pushed_at":"2015-03-18T06:01:26Z","git_url":"git://github.com/ambiata/notion.git","ssh_url":"git@github.com:ambiata/notion.git","clone_url":"https://github.com/ambiata/notion.git","svn_url":"https://github.com/ambiata/notion","homepage":null,"size":1623,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":9,"forks":0,"open_issues":9,"watchers":0,"default_branch":"master"}},"base":{"label":"ambiata:master","ref":"master","sha":"ae735722343853b69000a99e2eca9667ffc37540","user":{"login":"ambiata","id":1691023,"avatar_url":"https://avatars.githubusercontent.com/u/1691023?v=3","gravatar_id":"","url":"https://api.github.com/users/ambiata","html_url":"https://github.com/ambiata","followers_url":"https://api.github.com/users/ambiata/followers","following_url":"https://api.github.com/users/ambiata/following{/other_user}","gists_url":"https://api.github.com/users/ambiata/gists{/gist_id}","starred_url":"https://api.github.com/users/ambiata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ambiata/subscriptions","organizations_url":"https://api.github.com/users/ambiata/orgs","repos_url":"https://api.github.com/users/ambiata/repos","events_url":"https://api.github.com/users/ambiata/events{/privacy}","received_events_url":"https://api.github.com/users/ambiata/received_events","type":"Organization","site_admin":false},"repo":{"id":25012772,"name":"notion","full_name":"ambiata/notion","owner":{"login":"ambiata","id":1691023,"avatar_url":"https://avatars.githubusercontent.com/u/1691023?v=3","gravatar_id":"","url":"https://api.github.com/users/ambiata","html_url":"https://github.com/ambiata","followers_url":"https://api.github.com/users/ambiata/followers","following_url":"https://api.github.com/users/ambiata/following{/other_user}","gists_url":"https://api.github.com/users/ambiata/gists{/gist_id}","starred_url":"https://api.github.com/users/ambiata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ambiata/subscriptions","organizations_url":"https://api.github.com/users/ambiata/orgs","repos_url":"https://api.github.com/users/ambiata/repos","events_url":"https://api.github.com/users/ambiata/events{/privacy}","received_events_url":"https://api.github.com/users/ambiata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ambiata/notion","description":"a general understanding; vague or imperfect conception or idea of something - in this case of file system like data storage abstractions","fork":false,"url":"https://api.github.com/repos/ambiata/notion","forks_url":"https://api.github.com/repos/ambiata/notion/forks","keys_url":"https://api.github.com/repos/ambiata/notion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ambiata/notion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ambiata/notion/teams","hooks_url":"https://api.github.com/repos/ambiata/notion/hooks","issue_events_url":"https://api.github.com/repos/ambiata/notion/issues/events{/number}","events_url":"https://api.github.com/repos/ambiata/notion/events","assignees_url":"https://api.github.com/repos/ambiata/notion/assignees{/user}","branches_url":"https://api.github.com/repos/ambiata/notion/branches{/branch}","tags_url":"https://api.github.com/repos/ambiata/notion/tags","blobs_url":"https://api.github.com/repos/ambiata/notion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ambiata/notion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ambiata/notion/git/refs{/sha}","trees_url":"https://api.github.com/repos/ambiata/notion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ambiata/notion/statuses/{sha}","languages_url":"https://api.github.com/repos/ambiata/notion/languages","stargazers_url":"https://api.github.com/repos/ambiata/notion/stargazers","contributors_url":"https://api.github.com/repos/ambiata/notion/contributors","subscribers_url":"https://api.github.com/repos/ambiata/notion/subscribers","subscription_url":"https://api.github.com/repos/ambiata/notion/subscription","commits_url":"https://api.github.com/repos/ambiata/notion/commits{/sha}","git_commits_url":"https://api.github.com/repos/ambiata/notion/git/commits{/sha}","comments_url":"https://api.github.com/repos/ambiata/notion/comments{/number}","issue_comment_url":"https://api.github.com/repos/ambiata/notion/issues/comments{/number}","contents_url":"https://api.github.com/repos/ambiata/notion/contents/{+path}","compare_url":"https://api.github.com/repos/ambiata/notion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ambiata/notion/merges","archive_url":"https://api.github.com/repos/ambiata/notion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ambiata/notion/downloads","issues_url":"https://api.github.com/repos/ambiata/notion/issues{/number}","pulls_url":"https://api.github.com/repos/ambiata/notion/pulls{/number}","milestones_url":"https://api.github.com/repos/ambiata/notion/milestones{/number}","notifications_url":"https://api.github.com/repos/ambiata/notion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ambiata/notion/labels{/name}","releases_url":"https://api.github.com/repos/ambiata/notion/releases{/id}","created_at":"2014-10-09T23:32:38Z","updated_at":"2015-03-18T00:39:38Z","pushed_at":"2015-03-18T06:01:26Z","git_url":"git://github.com/ambiata/notion.git","ssh_url":"git@github.com:ambiata/notion.git","clone_url":"https://github.com/ambiata/notion.git","svn_url":"https://github.com/ambiata/notion","homepage":null,"size":1623,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":9,"forks":0,"open_issues":9,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ambiata/notion/pulls/60"},"html":{"href":"https://github.com/ambiata/notion/pull/60"},"issue":{"href":"https://api.github.com/repos/ambiata/notion/issues/60"},"comments":{"href":"https://api.github.com/repos/ambiata/notion/issues/60/comments"},"review_comments":{"href":"https://api.github.com/repos/ambiata/notion/pulls/60/comments"},"review_comment":{"href":"https://api.github.com/repos/ambiata/notion/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ambiata/notion/pulls/60/commits"},"statuses":{"href":"https://api.github.com/repos/ambiata/notion/statuses/b495d1f8816d8a47f56bbad01baf04ce24747517"}}}}