{"action":"created","comment":{"url":"https://api.github.com/repos/avast/storage-client/pulls/comments/209979070","pull_request_review_id":146098114,"id":209979070,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTk3OTA3MA==","diff_hunk":"@@ -0,0 +1,162 @@\n+package com.avast.clients.storage.stor\n+\n+import java.io.ByteArrayInputStream\n+\n+import better.files.File\n+import cats.effect.Effect\n+import cats.syntax.all._\n+import com.avast.clients.storage._\n+import com.avast.scala.hashes.Sha256\n+import com.typesafe.config.{Config, ConfigFactory}\n+import com.typesafe.scalalogging.StrictLogging\n+import org.http4s._\n+import org.http4s.client.Client\n+import org.http4s.client.blaze.{BlazeClientConfig, Http1Client}\n+import org.http4s.headers.`Content-Length`\n+import pureconfig.modules.http4s.uriReader\n+import pureconfig.{CamelCase, ConfigFieldMapping, ProductHint}\n+\n+import scala.concurrent.ExecutionContext\n+import scala.concurrent.duration.Duration\n+import scala.language.higherKinds\n+import scala.util.control.NonFatal\n+\n+trait StorBackend[F[_]] extends StorageBackend[F]\n+\n+class DefaultStorBackend[F[_]](rootUri: Uri, httpClient: Client[F])(implicit F: Effect[F]) extends StorBackend[F] with StrictLogging {\n+\n+  override def head(sha256: Sha256): F[Either[StorageException, HeadResult]] = {\n+    logger.debug(s\"Checking presence of file $sha256 in Stor\")\n+\n+    try {\n+      val request = Request[F](\n+        Method.HEAD,\n+        rootUri / sha256.toString\n+      )\n+\n+      httpClient.fetch(request) { resp =>\n+        resp.status match {\n+          case Status.Ok =>\n+            `Content-Length`.from(resp.headers) match {\n+              case Some(`Content-Length`(length)) => F.pure(Right(HeadResult.Exists(length)))\n+              case None =>\n+                resp.bodyAsText.compile.last.map { body =>\n+                  Left(StorageException.InvalidResponseException(resp.status.code, body.toString, \"Missing Content-Length header\"))\n+                }\n+            }\n+          case Status.NotFound =>\n+            F.pure(Right(HeadResult.NotFound))\n+\n+          case _ =>\n+            resp.bodyAsText.compile.last.map { body =>\n+              Left(StorageException.InvalidResponseException(resp.status.code, body.toString, \"Unexpected status\"))\n+            }\n+        }\n+      }\n+    } catch {\n+      case NonFatal(e) => F.raiseError(e)","path":"stor/src/main/scala/com/avast/clients/storage/stor/StorBackend.scala","position":57,"original_position":57,"commit_id":"d21329e8af57882d56918752072c275d65284385","original_commit_id":"fa4509b76d9f1b6a684ec7cc6d675fbf8914dac3","user":{"login":"jendakol","id":1770097,"node_id":"MDQ6VXNlcjE3NzAwOTc=","avatar_url":"https://avatars3.githubusercontent.com/u/1770097?v=4","gravatar_id":"","url":"https://api.github.com/users/jendakol","html_url":"https://github.com/jendakol","followers_url":"https://api.github.com/users/jendakol/followers","following_url":"https://api.github.com/users/jendakol/following{/other_user}","gists_url":"https://api.github.com/users/jendakol/gists{/gist_id}","starred_url":"https://api.github.com/users/jendakol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jendakol/subscriptions","organizations_url":"https://api.github.com/users/jendakol/orgs","repos_url":"https://api.github.com/users/jendakol/repos","events_url":"https://api.github.com/users/jendakol/events{/privacy}","received_events_url":"https://api.github.com/users/jendakol/received_events","type":"User","site_admin":false},"body":"Well, this is kind of a question. Should be throwing an _unknown_ exception considered as fatal failure or as normal state? ;-)","created_at":"2018-08-14T14:42:57Z","updated_at":"2018-08-14T14:42:58Z","html_url":"https://github.com/avast/storage-client/pull/1#discussion_r209979070","pull_request_url":"https://api.github.com/repos/avast/storage-client/pulls/1","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/avast/storage-client/pulls/comments/209979070"},"html":{"href":"https://github.com/avast/storage-client/pull/1#discussion_r209979070"},"pull_request":{"href":"https://api.github.com/repos/avast/storage-client/pulls/1"}},"in_reply_to_id":209941251},"pull_request":{"url":"https://api.github.com/repos/avast/storage-client/pulls/1","id":208250230,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA4MjUwMjMw","html_url":"https://github.com/avast/storage-client/pull/1","diff_url":"https://github.com/avast/storage-client/pull/1.diff","patch_url":"https://github.com/avast/storage-client/pull/1.patch","issue_url":"https://api.github.com/repos/avast/storage-client/issues/1","number":1,"state":"open","locked":false,"title":"New generation","user":{"login":"jendakol","id":1770097,"node_id":"MDQ6VXNlcjE3NzAwOTc=","avatar_url":"https://avatars3.githubusercontent.com/u/1770097?v=4","gravatar_id":"","url":"https://api.github.com/users/jendakol","html_url":"https://github.com/jendakol","followers_url":"https://api.github.com/users/jendakol/followers","following_url":"https://api.github.com/users/jendakol/following{/other_user}","gists_url":"https://api.github.com/users/jendakol/gists{/gist_id}","starred_url":"https://api.github.com/users/jendakol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jendakol/subscriptions","organizations_url":"https://api.github.com/users/jendakol/orgs","repos_url":"https://api.github.com/users/jendakol/repos","events_url":"https://api.github.com/users/jendakol/events{/privacy}","received_events_url":"https://api.github.com/users/jendakol/received_events","type":"User","site_admin":false},"body":"* Reworked to new structure\r\n* Finally tagless\r\n\r\nThere is a lot of changes because it's refactoring of old StorClient. Interesting classes are:\r\n1. StorClient\r\n1. StorBackend\r\n1. storage package object","created_at":"2018-08-14T11:28:26Z","updated_at":"2018-08-14T14:42:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"44f081efe42a3e8794d9569f9761980ae23acc3f","assignee":null,"assignees":[],"requested_reviewers":[{"login":"petr-k","id":376925,"node_id":"MDQ6VXNlcjM3NjkyNQ==","avatar_url":"https://avatars2.githubusercontent.com/u/376925?v=4","gravatar_id":"","url":"https://api.github.com/users/petr-k","html_url":"https://github.com/petr-k","followers_url":"https://api.github.com/users/petr-k/followers","following_url":"https://api.github.com/users/petr-k/following{/other_user}","gists_url":"https://api.github.com/users/petr-k/gists{/gist_id}","starred_url":"https://api.github.com/users/petr-k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petr-k/subscriptions","organizations_url":"https://api.github.com/users/petr-k/orgs","repos_url":"https://api.github.com/users/petr-k/repos","events_url":"https://api.github.com/users/petr-k/events{/privacy}","received_events_url":"https://api.github.com/users/petr-k/received_events","type":"User","site_admin":false},{"login":"rpliva","id":11376905,"node_id":"MDQ6VXNlcjExMzc2OTA1","avatar_url":"https://avatars1.githubusercontent.com/u/11376905?v=4","gravatar_id":"","url":"https://api.github.com/users/rpliva","html_url":"https://github.com/rpliva","followers_url":"https://api.github.com/users/rpliva/followers","following_url":"https://api.github.com/users/rpliva/following{/other_user}","gists_url":"https://api.github.com/users/rpliva/gists{/gist_id}","starred_url":"https://api.github.com/users/rpliva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rpliva/subscriptions","organizations_url":"https://api.github.com/users/rpliva/orgs","repos_url":"https://api.github.com/users/rpliva/repos","events_url":"https://api.github.com/users/rpliva/events{/privacy}","received_events_url":"https://api.github.com/users/rpliva/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/avast/storage-client/pulls/1/commits","review_comments_url":"https://api.github.com/repos/avast/storage-client/pulls/1/comments","review_comment_url":"https://api.github.com/repos/avast/storage-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/avast/storage-client/issues/1/comments","statuses_url":"https://api.github.com/repos/avast/storage-client/statuses/d21329e8af57882d56918752072c275d65284385","head":{"label":"avast:StorBackend","ref":"StorBackend","sha":"d21329e8af57882d56918752072c275d65284385","user":{"login":"avast","id":3996079,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM5OTYwNzk=","avatar_url":"https://avatars1.githubusercontent.com/u/3996079?v=4","gravatar_id":"","url":"https://api.github.com/users/avast","html_url":"https://github.com/avast","followers_url":"https://api.github.com/users/avast/followers","following_url":"https://api.github.com/users/avast/following{/other_user}","gists_url":"https://api.github.com/users/avast/gists{/gist_id}","starred_url":"https://api.github.com/users/avast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avast/subscriptions","organizations_url":"https://api.github.com/users/avast/orgs","repos_url":"https://api.github.com/users/avast/repos","events_url":"https://api.github.com/users/avast/events{/privacy}","received_events_url":"https://api.github.com/users/avast/received_events","type":"Organization","site_admin":false},"repo":{"id":144025439,"node_id":"MDEwOlJlcG9zaXRvcnkxNDQwMjU0Mzk=","name":"storage-client","full_name":"avast/storage-client","owner":{"login":"avast","id":3996079,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM5OTYwNzk=","avatar_url":"https://avatars1.githubusercontent.com/u/3996079?v=4","gravatar_id":"","url":"https://api.github.com/users/avast","html_url":"https://github.com/avast","followers_url":"https://api.github.com/users/avast/followers","following_url":"https://api.github.com/users/avast/following{/other_user}","gists_url":"https://api.github.com/users/avast/gists{/gist_id}","starred_url":"https://api.github.com/users/avast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avast/subscriptions","organizations_url":"https://api.github.com/users/avast/orgs","repos_url":"https://api.github.com/users/avast/repos","events_url":"https://api.github.com/users/avast/events{/privacy}","received_events_url":"https://api.github.com/users/avast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/avast/storage-client","description":null,"fork":false,"url":"https://api.github.com/repos/avast/storage-client","forks_url":"https://api.github.com/repos/avast/storage-client/forks","keys_url":"https://api.github.com/repos/avast/storage-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avast/storage-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avast/storage-client/teams","hooks_url":"https://api.github.com/repos/avast/storage-client/hooks","issue_events_url":"https://api.github.com/repos/avast/storage-client/issues/events{/number}","events_url":"https://api.github.com/repos/avast/storage-client/events","assignees_url":"https://api.github.com/repos/avast/storage-client/assignees{/user}","branches_url":"https://api.github.com/repos/avast/storage-client/branches{/branch}","tags_url":"https://api.github.com/repos/avast/storage-client/tags","blobs_url":"https://api.github.com/repos/avast/storage-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avast/storage-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avast/storage-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/avast/storage-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avast/storage-client/statuses/{sha}","languages_url":"https://api.github.com/repos/avast/storage-client/languages","stargazers_url":"https://api.github.com/repos/avast/storage-client/stargazers","contributors_url":"https://api.github.com/repos/avast/storage-client/contributors","subscribers_url":"https://api.github.com/repos/avast/storage-client/subscribers","subscription_url":"https://api.github.com/repos/avast/storage-client/subscription","commits_url":"https://api.github.com/repos/avast/storage-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/avast/storage-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/avast/storage-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/avast/storage-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/avast/storage-client/contents/{+path}","compare_url":"https://api.github.com/repos/avast/storage-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avast/storage-client/merges","archive_url":"https://api.github.com/repos/avast/storage-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avast/storage-client/downloads","issues_url":"https://api.github.com/repos/avast/storage-client/issues{/number}","pulls_url":"https://api.github.com/repos/avast/storage-client/pulls{/number}","milestones_url":"https://api.github.com/repos/avast/storage-client/milestones{/number}","notifications_url":"https://api.github.com/repos/avast/storage-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avast/storage-client/labels{/name}","releases_url":"https://api.github.com/repos/avast/storage-client/releases{/id}","deployments_url":"https://api.github.com/repos/avast/storage-client/deployments","created_at":"2018-08-08T14:29:06Z","updated_at":"2018-08-08T14:29:22Z","pushed_at":"2018-08-14T12:15:12Z","git_url":"git://github.com/avast/storage-client.git","ssh_url":"git@github.com:avast/storage-client.git","clone_url":"https://github.com/avast/storage-client.git","svn_url":"https://github.com/avast/storage-client","homepage":null,"size":78,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"avast:master","ref":"master","sha":"e4df5ff52760ef3c9b078514fdcd1089c9be135b","user":{"login":"avast","id":3996079,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM5OTYwNzk=","avatar_url":"https://avatars1.githubusercontent.com/u/3996079?v=4","gravatar_id":"","url":"https://api.github.com/users/avast","html_url":"https://github.com/avast","followers_url":"https://api.github.com/users/avast/followers","following_url":"https://api.github.com/users/avast/following{/other_user}","gists_url":"https://api.github.com/users/avast/gists{/gist_id}","starred_url":"https://api.github.com/users/avast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avast/subscriptions","organizations_url":"https://api.github.com/users/avast/orgs","repos_url":"https://api.github.com/users/avast/repos","events_url":"https://api.github.com/users/avast/events{/privacy}","received_events_url":"https://api.github.com/users/avast/received_events","type":"Organization","site_admin":false},"repo":{"id":144025439,"node_id":"MDEwOlJlcG9zaXRvcnkxNDQwMjU0Mzk=","name":"storage-client","full_name":"avast/storage-client","owner":{"login":"avast","id":3996079,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM5OTYwNzk=","avatar_url":"https://avatars1.githubusercontent.com/u/3996079?v=4","gravatar_id":"","url":"https://api.github.com/users/avast","html_url":"https://github.com/avast","followers_url":"https://api.github.com/users/avast/followers","following_url":"https://api.github.com/users/avast/following{/other_user}","gists_url":"https://api.github.com/users/avast/gists{/gist_id}","starred_url":"https://api.github.com/users/avast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avast/subscriptions","organizations_url":"https://api.github.com/users/avast/orgs","repos_url":"https://api.github.com/users/avast/repos","events_url":"https://api.github.com/users/avast/events{/privacy}","received_events_url":"https://api.github.com/users/avast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/avast/storage-client","description":null,"fork":false,"url":"https://api.github.com/repos/avast/storage-client","forks_url":"https://api.github.com/repos/avast/storage-client/forks","keys_url":"https://api.github.com/repos/avast/storage-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avast/storage-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avast/storage-client/teams","hooks_url":"https://api.github.com/repos/avast/storage-client/hooks","issue_events_url":"https://api.github.com/repos/avast/storage-client/issues/events{/number}","events_url":"https://api.github.com/repos/avast/storage-client/events","assignees_url":"https://api.github.com/repos/avast/storage-client/assignees{/user}","branches_url":"https://api.github.com/repos/avast/storage-client/branches{/branch}","tags_url":"https://api.github.com/repos/avast/storage-client/tags","blobs_url":"https://api.github.com/repos/avast/storage-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avast/storage-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avast/storage-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/avast/storage-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avast/storage-client/statuses/{sha}","languages_url":"https://api.github.com/repos/avast/storage-client/languages","stargazers_url":"https://api.github.com/repos/avast/storage-client/stargazers","contributors_url":"https://api.github.com/repos/avast/storage-client/contributors","subscribers_url":"https://api.github.com/repos/avast/storage-client/subscribers","subscription_url":"https://api.github.com/repos/avast/storage-client/subscription","commits_url":"https://api.github.com/repos/avast/storage-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/avast/storage-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/avast/storage-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/avast/storage-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/avast/storage-client/contents/{+path}","compare_url":"https://api.github.com/repos/avast/storage-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avast/storage-client/merges","archive_url":"https://api.github.com/repos/avast/storage-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avast/storage-client/downloads","issues_url":"https://api.github.com/repos/avast/storage-client/issues{/number}","pulls_url":"https://api.github.com/repos/avast/storage-client/pulls{/number}","milestones_url":"https://api.github.com/repos/avast/storage-client/milestones{/number}","notifications_url":"https://api.github.com/repos/avast/storage-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avast/storage-client/labels{/name}","releases_url":"https://api.github.com/repos/avast/storage-client/releases{/id}","deployments_url":"https://api.github.com/repos/avast/storage-client/deployments","created_at":"2018-08-08T14:29:06Z","updated_at":"2018-08-08T14:29:22Z","pushed_at":"2018-08-14T12:15:12Z","git_url":"git://github.com/avast/storage-client.git","ssh_url":"git@github.com:avast/storage-client.git","clone_url":"https://github.com/avast/storage-client.git","svn_url":"https://github.com/avast/storage-client","homepage":null,"size":78,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/avast/storage-client/pulls/1"},"html":{"href":"https://github.com/avast/storage-client/pull/1"},"issue":{"href":"https://api.github.com/repos/avast/storage-client/issues/1"},"comments":{"href":"https://api.github.com/repos/avast/storage-client/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/avast/storage-client/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/avast/storage-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/avast/storage-client/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/avast/storage-client/statuses/d21329e8af57882d56918752072c275d65284385"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"jendakol"}}