{"action":"created","comment":{"url":"https://api.github.com/repos/loic-sharma/BaGet/pulls/comments/206363027","pull_request_review_id":141764470,"id":206363027,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjM2MzAyNw==","diff_hunk":"@@ -44,7 +46,9 @@ public class IndexingService : IIndexingService\n                     var packageId = packageReader.NuspecReader.GetId();\r\n                     var packageVersion = packageReader.NuspecReader.GetVersion();\r\n \r\n-                    if (await _packages.ExistsAsync(packageId, packageVersion))\r\n+                    var identity = new PackageIdentity(packageId, packageVersion);\r\n+\r\n+                    if (await _storage.ExistsAsync(identity))\r","path":"src/BaGet.Core/Services/IndexingService.cs","position":21,"original_position":21,"commit_id":"15b305971447144c6e55759a9be2698133ace03b","original_commit_id":"15b305971447144c6e55759a9be2698133ace03b","user":{"login":"loic-sharma","id":737941,"node_id":"MDQ6VXNlcjczNzk0MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/737941?v=4","gravatar_id":"","url":"https://api.github.com/users/loic-sharma","html_url":"https://github.com/loic-sharma","followers_url":"https://api.github.com/users/loic-sharma/followers","following_url":"https://api.github.com/users/loic-sharma/following{/other_user}","gists_url":"https://api.github.com/users/loic-sharma/gists{/gist_id}","starred_url":"https://api.github.com/users/loic-sharma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loic-sharma/subscriptions","organizations_url":"https://api.github.com/users/loic-sharma/orgs","repos_url":"https://api.github.com/users/loic-sharma/repos","events_url":"https://api.github.com/users/loic-sharma/events{/privacy}","received_events_url":"https://api.github.com/users/loic-sharma/received_events","type":"User","site_admin":false},"body":"We should not fail uploads if the package already exists in storage. Consider the following scenario:\r\n\r\n1. A customer starts a package upload\r\n2. The package is uploaded to storage\r\n3. BaGet throws an exception before the package's metadata is persisted to the database\r\n\r\nIf we fail uploads when the package already exists in storage, we are now in an unrecoverable state. An admin needs to go manually delete the package from storage. The solution to these problems is to make the database the single source of truth.","created_at":"2018-07-31T00:26:56Z","updated_at":"2018-07-31T00:26:56Z","html_url":"https://github.com/loic-sharma/BaGet/pull/64#discussion_r206363027","pull_request_url":"https://api.github.com/repos/loic-sharma/BaGet/pulls/64","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/loic-sharma/BaGet/pulls/comments/206363027"},"html":{"href":"https://github.com/loic-sharma/BaGet/pull/64#discussion_r206363027"},"pull_request":{"href":"https://api.github.com/repos/loic-sharma/BaGet/pulls/64"}}},"pull_request":{"url":"https://api.github.com/repos/loic-sharma/BaGet/pulls/64","id":204963510,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA0OTYzNTEw","html_url":"https://github.com/loic-sharma/BaGet/pull/64","diff_url":"https://github.com/loic-sharma/BaGet/pull/64.diff","patch_url":"https://github.com/loic-sharma/BaGet/pull/64.patch","issue_url":"https://api.github.com/repos/loic-sharma/BaGet/issues/64","number":64,"state":"open","locked":false,"title":"write file to disk if it doesn't exist","user":{"login":"smazurov","id":21636,"node_id":"MDQ6VXNlcjIxNjM2","avatar_url":"https://avatars2.githubusercontent.com/u/21636?v=4","gravatar_id":"","url":"https://api.github.com/users/smazurov","html_url":"https://github.com/smazurov","followers_url":"https://api.github.com/users/smazurov/followers","following_url":"https://api.github.com/users/smazurov/following{/other_user}","gists_url":"https://api.github.com/users/smazurov/gists{/gist_id}","starred_url":"https://api.github.com/users/smazurov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smazurov/subscriptions","organizations_url":"https://api.github.com/users/smazurov/orgs","repos_url":"https://api.github.com/users/smazurov/repos","events_url":"https://api.github.com/users/smazurov/events{/privacy}","received_events_url":"https://api.github.com/users/smazurov/received_events","type":"User","site_admin":false},"body":"### What does this PR do?\r\n\r\nIf a file is in the db, but not on disk, currently registration fails with 409, without updating file on disk. This PR re-saves file to disk (if for instance, it was deleted or not persisted)\r\n\r\n### Motivation\r\n\r\nAs I was setting it up to host our internal nuget packages, I kept running conflict issues when my files weren't even there. My motivation was to harden the implementation a little bit, without changing any of the client expectations (it will still return a 409, for instance) ","created_at":"2018-07-31T00:11:47Z","updated_at":"2018-07-31T00:26:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"911c7f0a17d2f1c31620a6c9982ab989337d797f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/loic-sharma/BaGet/pulls/64/commits","review_comments_url":"https://api.github.com/repos/loic-sharma/BaGet/pulls/64/comments","review_comment_url":"https://api.github.com/repos/loic-sharma/BaGet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/loic-sharma/BaGet/issues/64/comments","statuses_url":"https://api.github.com/repos/loic-sharma/BaGet/statuses/15b305971447144c6e55759a9be2698133ace03b","head":{"label":"smazurov:improve-exists-logic","ref":"improve-exists-logic","sha":"15b305971447144c6e55759a9be2698133ace03b","user":{"login":"smazurov","id":21636,"node_id":"MDQ6VXNlcjIxNjM2","avatar_url":"https://avatars2.githubusercontent.com/u/21636?v=4","gravatar_id":"","url":"https://api.github.com/users/smazurov","html_url":"https://github.com/smazurov","followers_url":"https://api.github.com/users/smazurov/followers","following_url":"https://api.github.com/users/smazurov/following{/other_user}","gists_url":"https://api.github.com/users/smazurov/gists{/gist_id}","starred_url":"https://api.github.com/users/smazurov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smazurov/subscriptions","organizations_url":"https://api.github.com/users/smazurov/orgs","repos_url":"https://api.github.com/users/smazurov/repos","events_url":"https://api.github.com/users/smazurov/events{/privacy}","received_events_url":"https://api.github.com/users/smazurov/received_events","type":"User","site_admin":false},"repo":{"id":142939138,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI5MzkxMzg=","name":"BaGet","full_name":"smazurov/BaGet","owner":{"login":"smazurov","id":21636,"node_id":"MDQ6VXNlcjIxNjM2","avatar_url":"https://avatars2.githubusercontent.com/u/21636?v=4","gravatar_id":"","url":"https://api.github.com/users/smazurov","html_url":"https://github.com/smazurov","followers_url":"https://api.github.com/users/smazurov/followers","following_url":"https://api.github.com/users/smazurov/following{/other_user}","gists_url":"https://api.github.com/users/smazurov/gists{/gist_id}","starred_url":"https://api.github.com/users/smazurov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smazurov/subscriptions","organizations_url":"https://api.github.com/users/smazurov/orgs","repos_url":"https://api.github.com/users/smazurov/repos","events_url":"https://api.github.com/users/smazurov/events{/privacy}","received_events_url":"https://api.github.com/users/smazurov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smazurov/BaGet","description":"A lightweight NuGet Service implementation ","fork":true,"url":"https://api.github.com/repos/smazurov/BaGet","forks_url":"https://api.github.com/repos/smazurov/BaGet/forks","keys_url":"https://api.github.com/repos/smazurov/BaGet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smazurov/BaGet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smazurov/BaGet/teams","hooks_url":"https://api.github.com/repos/smazurov/BaGet/hooks","issue_events_url":"https://api.github.com/repos/smazurov/BaGet/issues/events{/number}","events_url":"https://api.github.com/repos/smazurov/BaGet/events","assignees_url":"https://api.github.com/repos/smazurov/BaGet/assignees{/user}","branches_url":"https://api.github.com/repos/smazurov/BaGet/branches{/branch}","tags_url":"https://api.github.com/repos/smazurov/BaGet/tags","blobs_url":"https://api.github.com/repos/smazurov/BaGet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smazurov/BaGet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smazurov/BaGet/git/refs{/sha}","trees_url":"https://api.github.com/repos/smazurov/BaGet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smazurov/BaGet/statuses/{sha}","languages_url":"https://api.github.com/repos/smazurov/BaGet/languages","stargazers_url":"https://api.github.com/repos/smazurov/BaGet/stargazers","contributors_url":"https://api.github.com/repos/smazurov/BaGet/contributors","subscribers_url":"https://api.github.com/repos/smazurov/BaGet/subscribers","subscription_url":"https://api.github.com/repos/smazurov/BaGet/subscription","commits_url":"https://api.github.com/repos/smazurov/BaGet/commits{/sha}","git_commits_url":"https://api.github.com/repos/smazurov/BaGet/git/commits{/sha}","comments_url":"https://api.github.com/repos/smazurov/BaGet/comments{/number}","issue_comment_url":"https://api.github.com/repos/smazurov/BaGet/issues/comments{/number}","contents_url":"https://api.github.com/repos/smazurov/BaGet/contents/{+path}","compare_url":"https://api.github.com/repos/smazurov/BaGet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smazurov/BaGet/merges","archive_url":"https://api.github.com/repos/smazurov/BaGet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smazurov/BaGet/downloads","issues_url":"https://api.github.com/repos/smazurov/BaGet/issues{/number}","pulls_url":"https://api.github.com/repos/smazurov/BaGet/pulls{/number}","milestones_url":"https://api.github.com/repos/smazurov/BaGet/milestones{/number}","notifications_url":"https://api.github.com/repos/smazurov/BaGet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smazurov/BaGet/labels{/name}","releases_url":"https://api.github.com/repos/smazurov/BaGet/releases{/id}","deployments_url":"https://api.github.com/repos/smazurov/BaGet/deployments","created_at":"2018-07-30T23:44:04Z","updated_at":"2018-07-30T23:44:06Z","pushed_at":"2018-07-31T00:08:58Z","git_url":"git://github.com/smazurov/BaGet.git","ssh_url":"git@github.com:smazurov/BaGet.git","clone_url":"https://github.com/smazurov/BaGet.git","svn_url":"https://github.com/smazurov/BaGet","homepage":"","size":1349,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"loic-sharma:master","ref":"master","sha":"ff72d234ff5d3682ed8f350e7e072025fade1870","user":{"login":"loic-sharma","id":737941,"node_id":"MDQ6VXNlcjczNzk0MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/737941?v=4","gravatar_id":"","url":"https://api.github.com/users/loic-sharma","html_url":"https://github.com/loic-sharma","followers_url":"https://api.github.com/users/loic-sharma/followers","following_url":"https://api.github.com/users/loic-sharma/following{/other_user}","gists_url":"https://api.github.com/users/loic-sharma/gists{/gist_id}","starred_url":"https://api.github.com/users/loic-sharma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loic-sharma/subscriptions","organizations_url":"https://api.github.com/users/loic-sharma/orgs","repos_url":"https://api.github.com/users/loic-sharma/repos","events_url":"https://api.github.com/users/loic-sharma/events{/privacy}","received_events_url":"https://api.github.com/users/loic-sharma/received_events","type":"User","site_admin":false},"repo":{"id":112103032,"node_id":"MDEwOlJlcG9zaXRvcnkxMTIxMDMwMzI=","name":"BaGet","full_name":"loic-sharma/BaGet","owner":{"login":"loic-sharma","id":737941,"node_id":"MDQ6VXNlcjczNzk0MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/737941?v=4","gravatar_id":"","url":"https://api.github.com/users/loic-sharma","html_url":"https://github.com/loic-sharma","followers_url":"https://api.github.com/users/loic-sharma/followers","following_url":"https://api.github.com/users/loic-sharma/following{/other_user}","gists_url":"https://api.github.com/users/loic-sharma/gists{/gist_id}","starred_url":"https://api.github.com/users/loic-sharma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loic-sharma/subscriptions","organizations_url":"https://api.github.com/users/loic-sharma/orgs","repos_url":"https://api.github.com/users/loic-sharma/repos","events_url":"https://api.github.com/users/loic-sharma/events{/privacy}","received_events_url":"https://api.github.com/users/loic-sharma/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/loic-sharma/BaGet","description":"A lightweight NuGet Service implementation ","fork":false,"url":"https://api.github.com/repos/loic-sharma/BaGet","forks_url":"https://api.github.com/repos/loic-sharma/BaGet/forks","keys_url":"https://api.github.com/repos/loic-sharma/BaGet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/loic-sharma/BaGet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/loic-sharma/BaGet/teams","hooks_url":"https://api.github.com/repos/loic-sharma/BaGet/hooks","issue_events_url":"https://api.github.com/repos/loic-sharma/BaGet/issues/events{/number}","events_url":"https://api.github.com/repos/loic-sharma/BaGet/events","assignees_url":"https://api.github.com/repos/loic-sharma/BaGet/assignees{/user}","branches_url":"https://api.github.com/repos/loic-sharma/BaGet/branches{/branch}","tags_url":"https://api.github.com/repos/loic-sharma/BaGet/tags","blobs_url":"https://api.github.com/repos/loic-sharma/BaGet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/loic-sharma/BaGet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/loic-sharma/BaGet/git/refs{/sha}","trees_url":"https://api.github.com/repos/loic-sharma/BaGet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/loic-sharma/BaGet/statuses/{sha}","languages_url":"https://api.github.com/repos/loic-sharma/BaGet/languages","stargazers_url":"https://api.github.com/repos/loic-sharma/BaGet/stargazers","contributors_url":"https://api.github.com/repos/loic-sharma/BaGet/contributors","subscribers_url":"https://api.github.com/repos/loic-sharma/BaGet/subscribers","subscription_url":"https://api.github.com/repos/loic-sharma/BaGet/subscription","commits_url":"https://api.github.com/repos/loic-sharma/BaGet/commits{/sha}","git_commits_url":"https://api.github.com/repos/loic-sharma/BaGet/git/commits{/sha}","comments_url":"https://api.github.com/repos/loic-sharma/BaGet/comments{/number}","issue_comment_url":"https://api.github.com/repos/loic-sharma/BaGet/issues/comments{/number}","contents_url":"https://api.github.com/repos/loic-sharma/BaGet/contents/{+path}","compare_url":"https://api.github.com/repos/loic-sharma/BaGet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/loic-sharma/BaGet/merges","archive_url":"https://api.github.com/repos/loic-sharma/BaGet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/loic-sharma/BaGet/downloads","issues_url":"https://api.github.com/repos/loic-sharma/BaGet/issues{/number}","pulls_url":"https://api.github.com/repos/loic-sharma/BaGet/pulls{/number}","milestones_url":"https://api.github.com/repos/loic-sharma/BaGet/milestones{/number}","notifications_url":"https://api.github.com/repos/loic-sharma/BaGet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/loic-sharma/BaGet/labels{/name}","releases_url":"https://api.github.com/repos/loic-sharma/BaGet/releases{/id}","deployments_url":"https://api.github.com/repos/loic-sharma/BaGet/deployments","created_at":"2017-11-26T17:37:18Z","updated_at":"2018-07-30T09:55:08Z","pushed_at":"2018-07-31T00:14:36Z","git_url":"git://github.com/loic-sharma/BaGet.git","ssh_url":"git@github.com:loic-sharma/BaGet.git","clone_url":"https://github.com/loic-sharma/BaGet.git","svn_url":"https://github.com/loic-sharma/BaGet","homepage":"","size":1349,"stargazers_count":27,"watchers_count":27,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"archived":false,"open_issues_count":40,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":12,"open_issues":40,"watchers":27,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/loic-sharma/BaGet/pulls/64"},"html":{"href":"https://github.com/loic-sharma/BaGet/pull/64"},"issue":{"href":"https://api.github.com/repos/loic-sharma/BaGet/issues/64"},"comments":{"href":"https://api.github.com/repos/loic-sharma/BaGet/issues/64/comments"},"review_comments":{"href":"https://api.github.com/repos/loic-sharma/BaGet/pulls/64/comments"},"review_comment":{"href":"https://api.github.com/repos/loic-sharma/BaGet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/loic-sharma/BaGet/pulls/64/commits"},"statuses":{"href":"https://api.github.com/repos/loic-sharma/BaGet/statuses/15b305971447144c6e55759a9be2698133ace03b"}},"author_association":"NONE"}}
{"actor":{"display_login":"loic-sharma"}}