{"action":"created","comment":{"url":"https://api.github.com/repos/clearlinux/swupd-client/pulls/comments/177848564","pull_request_review_id":107790326,"id":177848564,"diff_hunk":"@@ -38,86 +38,159 @@\n #include \"swupd.h\"\n #include \"xattrs.h\"\n \n-static void do_delta(char *filename, struct file *file);\n-\n-void try_delta(struct file *file)\n+static bool compute_hash_from_file(char *filename, char *hash)\n {\n-\tchar *filename;\n-\tstruct stat stat;\n+\t/* TODO: implement this without the indirection of creating a file... */\n+\tstruct file f = {};\n \n-\tif (file->is_file == 0) {\n-\t\treturn;\n-\t}\n+\tf.filename = filename;\n+\tf.use_xattrs = true;\n \n-\tif (file->deltapeer == NULL) {\n-\t\treturn;\n+\tpopulate_file_struct(&f, filename);\n+\tif (compute_hash(&f, filename) != 0) {\n+\t\treturn false;\n \t}\n \n-\tif (file->deltapeer->is_file == 0) {\n-\t\treturn;\n-\t}\n+\thash_assign(&f.hash[0], hash);\n+\treturn true;\n+}\n \n-\tif (file->deltapeer->is_deleted) {\n-\t\treturn;\n+static void apply_one_delta(char *from_file, char *to_staged, char *delta_file, char *to_hash)\n+{\n+\tint ret;\n+\n+\tchar *prefixed_from_file;\n+\tstring_or_die(&prefixed_from_file, \"%s/%s\", path_prefix, from_file);\n+\n+\tret = apply_bsdiff_delta(prefixed_from_file, to_staged, delta_file);","path":"src/delta.c","position":43,"original_position":43,"commit_id":"35c906910c83988cd36bcf1b69e6dc97e63fe89a","original_commit_id":"35c906910c83988cd36bcf1b69e6dc97e63fe89a","user":{"login":"icarus-sparry","id":21295823,"avatar_url":"https://avatars1.githubusercontent.com/u/21295823?v=4","gravatar_id":"","url":"https://api.github.com/users/icarus-sparry","html_url":"https://github.com/icarus-sparry","followers_url":"https://api.github.com/users/icarus-sparry/followers","following_url":"https://api.github.com/users/icarus-sparry/following{/other_user}","gists_url":"https://api.github.com/users/icarus-sparry/gists{/gist_id}","starred_url":"https://api.github.com/users/icarus-sparry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/icarus-sparry/subscriptions","organizations_url":"https://api.github.com/users/icarus-sparry/orgs","repos_url":"https://api.github.com/users/icarus-sparry/repos","events_url":"https://api.github.com/users/icarus-sparry/events{/privacy}","received_events_url":"https://api.github.com/users/icarus-sparry/received_events","type":"User","site_admin":false},"body":"Should we check the hash of the prefixed_from_file here?\r\nBetter still should we copy the prefixed from file to a secure location and then check the copy?\r\nOtherwise we open ourselves up to the file being changed either before or during the update, which might put bsdiff into an infinite loop.","created_at":"2018-03-28T18:32:44Z","updated_at":"2018-03-28T18:36:41Z","html_url":"https://github.com/clearlinux/swupd-client/pull/379#discussion_r177848564","pull_request_url":"https://api.github.com/repos/clearlinux/swupd-client/pulls/379","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/clearlinux/swupd-client/pulls/comments/177848564"},"html":{"href":"https://github.com/clearlinux/swupd-client/pull/379#discussion_r177848564"},"pull_request":{"href":"https://api.github.com/repos/clearlinux/swupd-client/pulls/379"}}},"pull_request":{"url":"https://api.github.com/repos/clearlinux/swupd-client/pulls/379","id":168714129,"html_url":"https://github.com/clearlinux/swupd-client/pull/379","diff_url":"https://github.com/clearlinux/swupd-client/pull/379.diff","patch_url":"https://github.com/clearlinux/swupd-client/pull/379.patch","issue_url":"https://api.github.com/repos/clearlinux/swupd-client/issues/379","number":379,"state":"open","locked":false,"title":"Apply all possible deltas from the pack, not only renames","user":{"login":"cmarcelo","id":10478,"avatar_url":"https://avatars3.githubusercontent.com/u/10478?v=4","gravatar_id":"","url":"https://api.github.com/users/cmarcelo","html_url":"https://github.com/cmarcelo","followers_url":"https://api.github.com/users/cmarcelo/followers","following_url":"https://api.github.com/users/cmarcelo/following{/other_user}","gists_url":"https://api.github.com/users/cmarcelo/gists{/gist_id}","starred_url":"https://api.github.com/users/cmarcelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmarcelo/subscriptions","organizations_url":"https://api.github.com/users/cmarcelo/orgs","repos_url":"https://api.github.com/users/cmarcelo/repos","events_url":"https://api.github.com/users/cmarcelo/events{/privacy}","received_events_url":"https://api.github.com/users/cmarcelo/received_events","type":"User","site_admin":false},"body":"Consider all deltas from a pack instead of only those who are involved\r\nin a rename. This will allow the server to make better packs\r\nregardless of the from/to version, with the possibility of a delta to\r\na file that was not necessarily marked with the rename flag.\r\n\r\nThis makes deltapeer member of file unused, so it was removed. The\r\npeer member continues to be used for its original role: mapping the\r\nsame files (same filename) between two manifests, usually the state of\r\nthe local system and some new version to be installed.","created_at":"2018-02-12T23:15:21Z","updated_at":"2018-03-28T18:36:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"85a734b8d2b7c284c2db3d5cc0b2068056b4224a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/clearlinux/swupd-client/pulls/379/commits","review_comments_url":"https://api.github.com/repos/clearlinux/swupd-client/pulls/379/comments","review_comment_url":"https://api.github.com/repos/clearlinux/swupd-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/clearlinux/swupd-client/issues/379/comments","statuses_url":"https://api.github.com/repos/clearlinux/swupd-client/statuses/35c906910c83988cd36bcf1b69e6dc97e63fe89a","head":{"label":"cmarcelo:no-renames","ref":"no-renames","sha":"35c906910c83988cd36bcf1b69e6dc97e63fe89a","user":{"login":"cmarcelo","id":10478,"avatar_url":"https://avatars3.githubusercontent.com/u/10478?v=4","gravatar_id":"","url":"https://api.github.com/users/cmarcelo","html_url":"https://github.com/cmarcelo","followers_url":"https://api.github.com/users/cmarcelo/followers","following_url":"https://api.github.com/users/cmarcelo/following{/other_user}","gists_url":"https://api.github.com/users/cmarcelo/gists{/gist_id}","starred_url":"https://api.github.com/users/cmarcelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmarcelo/subscriptions","organizations_url":"https://api.github.com/users/cmarcelo/orgs","repos_url":"https://api.github.com/users/cmarcelo/repos","events_url":"https://api.github.com/users/cmarcelo/events{/privacy}","received_events_url":"https://api.github.com/users/cmarcelo/received_events","type":"User","site_admin":false},"repo":{"id":101003792,"name":"swupd-client","full_name":"cmarcelo/swupd-client","owner":{"login":"cmarcelo","id":10478,"avatar_url":"https://avatars3.githubusercontent.com/u/10478?v=4","gravatar_id":"","url":"https://api.github.com/users/cmarcelo","html_url":"https://github.com/cmarcelo","followers_url":"https://api.github.com/users/cmarcelo/followers","following_url":"https://api.github.com/users/cmarcelo/following{/other_user}","gists_url":"https://api.github.com/users/cmarcelo/gists{/gist_id}","starred_url":"https://api.github.com/users/cmarcelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmarcelo/subscriptions","organizations_url":"https://api.github.com/users/cmarcelo/orgs","repos_url":"https://api.github.com/users/cmarcelo/repos","events_url":"https://api.github.com/users/cmarcelo/events{/privacy}","received_events_url":"https://api.github.com/users/cmarcelo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cmarcelo/swupd-client","description":"Software update client","fork":true,"url":"https://api.github.com/repos/cmarcelo/swupd-client","forks_url":"https://api.github.com/repos/cmarcelo/swupd-client/forks","keys_url":"https://api.github.com/repos/cmarcelo/swupd-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cmarcelo/swupd-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cmarcelo/swupd-client/teams","hooks_url":"https://api.github.com/repos/cmarcelo/swupd-client/hooks","issue_events_url":"https://api.github.com/repos/cmarcelo/swupd-client/issues/events{/number}","events_url":"https://api.github.com/repos/cmarcelo/swupd-client/events","assignees_url":"https://api.github.com/repos/cmarcelo/swupd-client/assignees{/user}","branches_url":"https://api.github.com/repos/cmarcelo/swupd-client/branches{/branch}","tags_url":"https://api.github.com/repos/cmarcelo/swupd-client/tags","blobs_url":"https://api.github.com/repos/cmarcelo/swupd-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cmarcelo/swupd-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cmarcelo/swupd-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/cmarcelo/swupd-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cmarcelo/swupd-client/statuses/{sha}","languages_url":"https://api.github.com/repos/cmarcelo/swupd-client/languages","stargazers_url":"https://api.github.com/repos/cmarcelo/swupd-client/stargazers","contributors_url":"https://api.github.com/repos/cmarcelo/swupd-client/contributors","subscribers_url":"https://api.github.com/repos/cmarcelo/swupd-client/subscribers","subscription_url":"https://api.github.com/repos/cmarcelo/swupd-client/subscription","commits_url":"https://api.github.com/repos/cmarcelo/swupd-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/cmarcelo/swupd-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/cmarcelo/swupd-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/cmarcelo/swupd-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/cmarcelo/swupd-client/contents/{+path}","compare_url":"https://api.github.com/repos/cmarcelo/swupd-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cmarcelo/swupd-client/merges","archive_url":"https://api.github.com/repos/cmarcelo/swupd-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cmarcelo/swupd-client/downloads","issues_url":"https://api.github.com/repos/cmarcelo/swupd-client/issues{/number}","pulls_url":"https://api.github.com/repos/cmarcelo/swupd-client/pulls{/number}","milestones_url":"https://api.github.com/repos/cmarcelo/swupd-client/milestones{/number}","notifications_url":"https://api.github.com/repos/cmarcelo/swupd-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cmarcelo/swupd-client/labels{/name}","releases_url":"https://api.github.com/repos/cmarcelo/swupd-client/releases{/id}","deployments_url":"https://api.github.com/repos/cmarcelo/swupd-client/deployments","created_at":"2017-08-22T00:33:30Z","updated_at":"2017-08-22T00:33:33Z","pushed_at":"2018-03-27T17:53:13Z","git_url":"git://github.com/cmarcelo/swupd-client.git","ssh_url":"git@github.com:cmarcelo/swupd-client.git","clone_url":"https://github.com/cmarcelo/swupd-client.git","svn_url":"https://github.com/cmarcelo/swupd-client","homepage":null,"size":1696,"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":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"clearlinux:master","ref":"master","sha":"bc5cae81dc5ea02f1f571a8f47a97491dbaf7ce5","user":{"login":"clearlinux","id":12545216,"avatar_url":"https://avatars2.githubusercontent.com/u/12545216?v=4","gravatar_id":"","url":"https://api.github.com/users/clearlinux","html_url":"https://github.com/clearlinux","followers_url":"https://api.github.com/users/clearlinux/followers","following_url":"https://api.github.com/users/clearlinux/following{/other_user}","gists_url":"https://api.github.com/users/clearlinux/gists{/gist_id}","starred_url":"https://api.github.com/users/clearlinux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clearlinux/subscriptions","organizations_url":"https://api.github.com/users/clearlinux/orgs","repos_url":"https://api.github.com/users/clearlinux/repos","events_url":"https://api.github.com/users/clearlinux/events{/privacy}","received_events_url":"https://api.github.com/users/clearlinux/received_events","type":"Organization","site_admin":false},"repo":{"id":52470178,"name":"swupd-client","full_name":"clearlinux/swupd-client","owner":{"login":"clearlinux","id":12545216,"avatar_url":"https://avatars2.githubusercontent.com/u/12545216?v=4","gravatar_id":"","url":"https://api.github.com/users/clearlinux","html_url":"https://github.com/clearlinux","followers_url":"https://api.github.com/users/clearlinux/followers","following_url":"https://api.github.com/users/clearlinux/following{/other_user}","gists_url":"https://api.github.com/users/clearlinux/gists{/gist_id}","starred_url":"https://api.github.com/users/clearlinux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clearlinux/subscriptions","organizations_url":"https://api.github.com/users/clearlinux/orgs","repos_url":"https://api.github.com/users/clearlinux/repos","events_url":"https://api.github.com/users/clearlinux/events{/privacy}","received_events_url":"https://api.github.com/users/clearlinux/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clearlinux/swupd-client","description":"Software update client","fork":false,"url":"https://api.github.com/repos/clearlinux/swupd-client","forks_url":"https://api.github.com/repos/clearlinux/swupd-client/forks","keys_url":"https://api.github.com/repos/clearlinux/swupd-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clearlinux/swupd-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clearlinux/swupd-client/teams","hooks_url":"https://api.github.com/repos/clearlinux/swupd-client/hooks","issue_events_url":"https://api.github.com/repos/clearlinux/swupd-client/issues/events{/number}","events_url":"https://api.github.com/repos/clearlinux/swupd-client/events","assignees_url":"https://api.github.com/repos/clearlinux/swupd-client/assignees{/user}","branches_url":"https://api.github.com/repos/clearlinux/swupd-client/branches{/branch}","tags_url":"https://api.github.com/repos/clearlinux/swupd-client/tags","blobs_url":"https://api.github.com/repos/clearlinux/swupd-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clearlinux/swupd-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clearlinux/swupd-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/clearlinux/swupd-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clearlinux/swupd-client/statuses/{sha}","languages_url":"https://api.github.com/repos/clearlinux/swupd-client/languages","stargazers_url":"https://api.github.com/repos/clearlinux/swupd-client/stargazers","contributors_url":"https://api.github.com/repos/clearlinux/swupd-client/contributors","subscribers_url":"https://api.github.com/repos/clearlinux/swupd-client/subscribers","subscription_url":"https://api.github.com/repos/clearlinux/swupd-client/subscription","commits_url":"https://api.github.com/repos/clearlinux/swupd-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/clearlinux/swupd-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/clearlinux/swupd-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/clearlinux/swupd-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/clearlinux/swupd-client/contents/{+path}","compare_url":"https://api.github.com/repos/clearlinux/swupd-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clearlinux/swupd-client/merges","archive_url":"https://api.github.com/repos/clearlinux/swupd-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clearlinux/swupd-client/downloads","issues_url":"https://api.github.com/repos/clearlinux/swupd-client/issues{/number}","pulls_url":"https://api.github.com/repos/clearlinux/swupd-client/pulls{/number}","milestones_url":"https://api.github.com/repos/clearlinux/swupd-client/milestones{/number}","notifications_url":"https://api.github.com/repos/clearlinux/swupd-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clearlinux/swupd-client/labels{/name}","releases_url":"https://api.github.com/repos/clearlinux/swupd-client/releases{/id}","deployments_url":"https://api.github.com/repos/clearlinux/swupd-client/deployments","created_at":"2016-02-24T19:54:13Z","updated_at":"2018-03-27T18:07:04Z","pushed_at":"2018-03-27T18:07:13Z","git_url":"git://github.com/clearlinux/swupd-client.git","ssh_url":"git@github.com:clearlinux/swupd-client.git","clone_url":"https://github.com/clearlinux/swupd-client.git","svn_url":"https://github.com/clearlinux/swupd-client","homepage":null,"size":1664,"stargazers_count":34,"watchers_count":34,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":35,"mirror_url":null,"archived":false,"open_issues_count":45,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":35,"open_issues":45,"watchers":34,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/clearlinux/swupd-client/pulls/379"},"html":{"href":"https://github.com/clearlinux/swupd-client/pull/379"},"issue":{"href":"https://api.github.com/repos/clearlinux/swupd-client/issues/379"},"comments":{"href":"https://api.github.com/repos/clearlinux/swupd-client/issues/379/comments"},"review_comments":{"href":"https://api.github.com/repos/clearlinux/swupd-client/pulls/379/comments"},"review_comment":{"href":"https://api.github.com/repos/clearlinux/swupd-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/clearlinux/swupd-client/pulls/379/commits"},"statuses":{"href":"https://api.github.com/repos/clearlinux/swupd-client/statuses/35c906910c83988cd36bcf1b69e6dc97e63fe89a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"icarus-sparry"}}