{"action":"created","comment":{"url":"https://api.github.com/repos/syncthing/syncthing/pulls/comments/46212326","id":46212326,"diff_hunk":"@@ -0,0 +1,102 @@\n+package fsops\n+\n+import (\n+\t\"fmt\"\n+\n+\t\"github.com/syncthing/syncthing/lib/protocol\"\n+)\n+\n+type TempNamer interface {\n+\t// Temporary returns a temporary name for the filed referred to by filepath.\n+\tTempName(path string) string\n+\t// IsTemporary returns true if path refers to the name of temporary file.\n+\tIsTemporary(path string) bool\n+}\n+\n+type CurrentFiler interface {\n+\t// CurrentFile returns the file as seen at last scan.\n+\tCurrentFile(name string) (protocol.FileInfo, bool)\n+}\n+\n+type IgnoreMatcher interface {\n+\t// Match returns true if the file should be ignored.\n+\tMatch(filename string) bool\n+}\n+\n+type Source interface {\n+\tRequest(file string, offset int64, hash []byte, buf []byte) error\n+}\n+\n+type Changeset struct {\n+\trootPath      string\n+\ttempNamer     TempNamer\n+\tlocalSource   Source\n+\tnetworkSource Source\n+\n+\tupdateFiles   []protocol.FileInfo\n+\tupdateDirs    []protocol.FileInfo\n+\tdeleteFiles   []protocol.FileInfo\n+\tdeleteDirs    []protocol.FileInfo\n+\tdeletedHashes map[string]protocol.FileInfo\n+\terrors        []error\n+}\n+\n+func NewChangeset(rootPath string, tempNamer TempNamer, localSource Source, networkSource Source) *Changeset {\n+\treturn &Changeset{\n+\t\trootPath:      rootPath,\n+\t\ttempNamer:     tempNamer,\n+\t\tlocalSource:   localSource,\n+\t\tnetworkSource: networkSource,\n+\t}\n+}\n+\n+// Queue adds a file (or directory) to the change set.\n+// In case of a deletion, the FileInfo should be modified to contain the block list of the *current* file.\n+func (c *Changeset) Queue(f protocol.FileInfo) {\n+\tif f.IsDirectory() {\n+\t\tif f.IsDeleted() {\n+\t\t\tc.deleteDirs = append(c.deleteDirs, f)\n+\t\t} else {\n+\t\t\tc.updateDirs = append(c.updateDirs, f)\n+\t\t}\n+\t} else {\n+\t\tif f.IsDeleted() {\n+\t\t\tkey := string(f.Hash())\n+\t\t\tf.Blocks = nil\n+\t\t\tc.deleteFiles = append(c.deleteFiles, f)\n+\t\t\tif c.deletedHashes == nil {\n+\t\t\t\tc.deletedHashes = make(map[string]protocol.FileInfo)","path":"lib/fsops/changeset.go","position":68,"original_position":68,"commit_id":"8866798f0d55b43fc34d6060f8f485b1cb49f88b","original_commit_id":"8866798f0d55b43fc34d6060f8f485b1cb49f88b","user":{"login":"AudriusButkevicius","id":1144861,"avatar_url":"https://avatars.githubusercontent.com/u/1144861?v=3","gravatar_id":"","url":"https://api.github.com/users/AudriusButkevicius","html_url":"https://github.com/AudriusButkevicius","followers_url":"https://api.github.com/users/AudriusButkevicius/followers","following_url":"https://api.github.com/users/AudriusButkevicius/following{/other_user}","gists_url":"https://api.github.com/users/AudriusButkevicius/gists{/gist_id}","starred_url":"https://api.github.com/users/AudriusButkevicius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AudriusButkevicius/subscriptions","organizations_url":"https://api.github.com/users/AudriusButkevicius/orgs","repos_url":"https://api.github.com/users/AudriusButkevicius/repos","events_url":"https://api.github.com/users/AudriusButkevicius/events{/privacy}","received_events_url":"https://api.github.com/users/AudriusButkevicius/received_events","type":"User","site_admin":false},"body":"Doing this in the constructor saves us from checking this if all the time.","created_at":"2015-11-30T22:18:43Z","updated_at":"2015-11-30T22:18:43Z","html_url":"https://github.com/syncthing/syncthing/pull/2540#discussion_r46212326","pull_request_url":"https://api.github.com/repos/syncthing/syncthing/pulls/2540","_links":{"self":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/comments/46212326"},"html":{"href":"https://github.com/syncthing/syncthing/pull/2540#discussion_r46212326"},"pull_request":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/2540"}}},"pull_request":{"url":"https://api.github.com/repos/syncthing/syncthing/pulls/2540","id":52179175,"html_url":"https://github.com/syncthing/syncthing/pull/2540","diff_url":"https://github.com/syncthing/syncthing/pull/2540.diff","patch_url":"https://github.com/syncthing/syncthing/pull/2540.patch","issue_url":"https://api.github.com/repos/syncthing/syncthing/issues/2540","number":2540,"state":"open","locked":false,"title":"Refactor pulling","user":{"login":"calmh","id":125426,"avatar_url":"https://avatars.githubusercontent.com/u/125426?v=3","gravatar_id":"","url":"https://api.github.com/users/calmh","html_url":"https://github.com/calmh","followers_url":"https://api.github.com/users/calmh/followers","following_url":"https://api.github.com/users/calmh/following{/other_user}","gists_url":"https://api.github.com/users/calmh/gists{/gist_id}","starred_url":"https://api.github.com/users/calmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calmh/subscriptions","organizations_url":"https://api.github.com/users/calmh/orgs","repos_url":"https://api.github.com/users/calmh/repos","events_url":"https://api.github.com/users/calmh/events{/privacy}","received_events_url":"https://api.github.com/users/calmh/received_events","type":"User","site_admin":false},"body":"This is the embryo of a new file puller mechanism. It's right about 10% done at most, but I want test results from Windows along the way and having it in a PR is the easiest way to do that.","created_at":"2015-11-30T21:07:53Z","updated_at":"2015-11-30T22:18:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e64fcd114387ac6f109cee056de1361c2e135e2c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/syncthing/syncthing/pulls/2540/commits","review_comments_url":"https://api.github.com/repos/syncthing/syncthing/pulls/2540/comments","review_comment_url":"https://api.github.com/repos/syncthing/syncthing/pulls/comments{/number}","comments_url":"https://api.github.com/repos/syncthing/syncthing/issues/2540/comments","statuses_url":"https://api.github.com/repos/syncthing/syncthing/statuses/8866798f0d55b43fc34d6060f8f485b1cb49f88b","head":{"label":"calmh:changeset","ref":"changeset","sha":"8866798f0d55b43fc34d6060f8f485b1cb49f88b","user":{"login":"calmh","id":125426,"avatar_url":"https://avatars.githubusercontent.com/u/125426?v=3","gravatar_id":"","url":"https://api.github.com/users/calmh","html_url":"https://github.com/calmh","followers_url":"https://api.github.com/users/calmh/followers","following_url":"https://api.github.com/users/calmh/following{/other_user}","gists_url":"https://api.github.com/users/calmh/gists{/gist_id}","starred_url":"https://api.github.com/users/calmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calmh/subscriptions","organizations_url":"https://api.github.com/users/calmh/orgs","repos_url":"https://api.github.com/users/calmh/repos","events_url":"https://api.github.com/users/calmh/events{/privacy}","received_events_url":"https://api.github.com/users/calmh/received_events","type":"User","site_admin":false},"repo":{"id":29292392,"name":"syncthing","full_name":"calmh/syncthing","owner":{"login":"calmh","id":125426,"avatar_url":"https://avatars.githubusercontent.com/u/125426?v=3","gravatar_id":"","url":"https://api.github.com/users/calmh","html_url":"https://github.com/calmh","followers_url":"https://api.github.com/users/calmh/followers","following_url":"https://api.github.com/users/calmh/following{/other_user}","gists_url":"https://api.github.com/users/calmh/gists{/gist_id}","starred_url":"https://api.github.com/users/calmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calmh/subscriptions","organizations_url":"https://api.github.com/users/calmh/orgs","repos_url":"https://api.github.com/users/calmh/repos","events_url":"https://api.github.com/users/calmh/events{/privacy}","received_events_url":"https://api.github.com/users/calmh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/calmh/syncthing","description":"This is my personal fork of the repo, not the official one! It may be outdated, broken, rebased upon and generally screwed around with. Don't watch it, star it, or fork from it! :)","fork":true,"url":"https://api.github.com/repos/calmh/syncthing","forks_url":"https://api.github.com/repos/calmh/syncthing/forks","keys_url":"https://api.github.com/repos/calmh/syncthing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/calmh/syncthing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/calmh/syncthing/teams","hooks_url":"https://api.github.com/repos/calmh/syncthing/hooks","issue_events_url":"https://api.github.com/repos/calmh/syncthing/issues/events{/number}","events_url":"https://api.github.com/repos/calmh/syncthing/events","assignees_url":"https://api.github.com/repos/calmh/syncthing/assignees{/user}","branches_url":"https://api.github.com/repos/calmh/syncthing/branches{/branch}","tags_url":"https://api.github.com/repos/calmh/syncthing/tags","blobs_url":"https://api.github.com/repos/calmh/syncthing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/calmh/syncthing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/calmh/syncthing/git/refs{/sha}","trees_url":"https://api.github.com/repos/calmh/syncthing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/calmh/syncthing/statuses/{sha}","languages_url":"https://api.github.com/repos/calmh/syncthing/languages","stargazers_url":"https://api.github.com/repos/calmh/syncthing/stargazers","contributors_url":"https://api.github.com/repos/calmh/syncthing/contributors","subscribers_url":"https://api.github.com/repos/calmh/syncthing/subscribers","subscription_url":"https://api.github.com/repos/calmh/syncthing/subscription","commits_url":"https://api.github.com/repos/calmh/syncthing/commits{/sha}","git_commits_url":"https://api.github.com/repos/calmh/syncthing/git/commits{/sha}","comments_url":"https://api.github.com/repos/calmh/syncthing/comments{/number}","issue_comment_url":"https://api.github.com/repos/calmh/syncthing/issues/comments{/number}","contents_url":"https://api.github.com/repos/calmh/syncthing/contents/{+path}","compare_url":"https://api.github.com/repos/calmh/syncthing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/calmh/syncthing/merges","archive_url":"https://api.github.com/repos/calmh/syncthing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/calmh/syncthing/downloads","issues_url":"https://api.github.com/repos/calmh/syncthing/issues{/number}","pulls_url":"https://api.github.com/repos/calmh/syncthing/pulls{/number}","milestones_url":"https://api.github.com/repos/calmh/syncthing/milestones{/number}","notifications_url":"https://api.github.com/repos/calmh/syncthing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/calmh/syncthing/labels{/name}","releases_url":"https://api.github.com/repos/calmh/syncthing/releases{/id}","created_at":"2015-01-15T10:31:42Z","updated_at":"2015-10-11T11:56:51Z","pushed_at":"2015-11-30T21:08:27Z","git_url":"git://github.com/calmh/syncthing.git","ssh_url":"git@github.com:calmh/syncthing.git","clone_url":"https://github.com/calmh/syncthing.git","svn_url":"https://github.com/calmh/syncthing","homepage":"https://github.com/syncthing/syncthing","size":60823,"stargazers_count":18,"watchers_count":18,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":0,"forks":5,"open_issues":0,"watchers":18,"default_branch":"master"}},"base":{"label":"syncthing:master","ref":"master","sha":"3008dc76d3c0caf1e939ff4399f169408e65c263","user":{"login":"syncthing","id":7628018,"avatar_url":"https://avatars.githubusercontent.com/u/7628018?v=3","gravatar_id":"","url":"https://api.github.com/users/syncthing","html_url":"https://github.com/syncthing","followers_url":"https://api.github.com/users/syncthing/followers","following_url":"https://api.github.com/users/syncthing/following{/other_user}","gists_url":"https://api.github.com/users/syncthing/gists{/gist_id}","starred_url":"https://api.github.com/users/syncthing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syncthing/subscriptions","organizations_url":"https://api.github.com/users/syncthing/orgs","repos_url":"https://api.github.com/users/syncthing/repos","events_url":"https://api.github.com/users/syncthing/events{/privacy}","received_events_url":"https://api.github.com/users/syncthing/received_events","type":"Organization","site_admin":false},"repo":{"id":14712850,"name":"syncthing","full_name":"syncthing/syncthing","owner":{"login":"syncthing","id":7628018,"avatar_url":"https://avatars.githubusercontent.com/u/7628018?v=3","gravatar_id":"","url":"https://api.github.com/users/syncthing","html_url":"https://github.com/syncthing","followers_url":"https://api.github.com/users/syncthing/followers","following_url":"https://api.github.com/users/syncthing/following{/other_user}","gists_url":"https://api.github.com/users/syncthing/gists{/gist_id}","starred_url":"https://api.github.com/users/syncthing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syncthing/subscriptions","organizations_url":"https://api.github.com/users/syncthing/orgs","repos_url":"https://api.github.com/users/syncthing/repos","events_url":"https://api.github.com/users/syncthing/events{/privacy}","received_events_url":"https://api.github.com/users/syncthing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/syncthing/syncthing","description":"Open Source Continuous File Synchronization","fork":false,"url":"https://api.github.com/repos/syncthing/syncthing","forks_url":"https://api.github.com/repos/syncthing/syncthing/forks","keys_url":"https://api.github.com/repos/syncthing/syncthing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/syncthing/syncthing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/syncthing/syncthing/teams","hooks_url":"https://api.github.com/repos/syncthing/syncthing/hooks","issue_events_url":"https://api.github.com/repos/syncthing/syncthing/issues/events{/number}","events_url":"https://api.github.com/repos/syncthing/syncthing/events","assignees_url":"https://api.github.com/repos/syncthing/syncthing/assignees{/user}","branches_url":"https://api.github.com/repos/syncthing/syncthing/branches{/branch}","tags_url":"https://api.github.com/repos/syncthing/syncthing/tags","blobs_url":"https://api.github.com/repos/syncthing/syncthing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/syncthing/syncthing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/syncthing/syncthing/git/refs{/sha}","trees_url":"https://api.github.com/repos/syncthing/syncthing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/syncthing/syncthing/statuses/{sha}","languages_url":"https://api.github.com/repos/syncthing/syncthing/languages","stargazers_url":"https://api.github.com/repos/syncthing/syncthing/stargazers","contributors_url":"https://api.github.com/repos/syncthing/syncthing/contributors","subscribers_url":"https://api.github.com/repos/syncthing/syncthing/subscribers","subscription_url":"https://api.github.com/repos/syncthing/syncthing/subscription","commits_url":"https://api.github.com/repos/syncthing/syncthing/commits{/sha}","git_commits_url":"https://api.github.com/repos/syncthing/syncthing/git/commits{/sha}","comments_url":"https://api.github.com/repos/syncthing/syncthing/comments{/number}","issue_comment_url":"https://api.github.com/repos/syncthing/syncthing/issues/comments{/number}","contents_url":"https://api.github.com/repos/syncthing/syncthing/contents/{+path}","compare_url":"https://api.github.com/repos/syncthing/syncthing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/syncthing/syncthing/merges","archive_url":"https://api.github.com/repos/syncthing/syncthing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/syncthing/syncthing/downloads","issues_url":"https://api.github.com/repos/syncthing/syncthing/issues{/number}","pulls_url":"https://api.github.com/repos/syncthing/syncthing/pulls{/number}","milestones_url":"https://api.github.com/repos/syncthing/syncthing/milestones{/number}","notifications_url":"https://api.github.com/repos/syncthing/syncthing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/syncthing/syncthing/labels{/name}","releases_url":"https://api.github.com/repos/syncthing/syncthing/releases{/id}","created_at":"2013-11-26T09:48:21Z","updated_at":"2015-11-30T22:01:15Z","pushed_at":"2015-11-30T21:08:27Z","git_url":"git://github.com/syncthing/syncthing.git","ssh_url":"git@github.com:syncthing/syncthing.git","clone_url":"https://github.com/syncthing/syncthing.git","svn_url":"https://github.com/syncthing/syncthing","homepage":"http://forum.syncthing.net/","size":65838,"stargazers_count":10522,"watchers_count":10522,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":779,"mirror_url":null,"open_issues_count":170,"forks":779,"open_issues":170,"watchers":10522,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/2540"},"html":{"href":"https://github.com/syncthing/syncthing/pull/2540"},"issue":{"href":"https://api.github.com/repos/syncthing/syncthing/issues/2540"},"comments":{"href":"https://api.github.com/repos/syncthing/syncthing/issues/2540/comments"},"review_comments":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/2540/comments"},"review_comment":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/2540/commits"},"statuses":{"href":"https://api.github.com/repos/syncthing/syncthing/statuses/8866798f0d55b43fc34d6060f8f485b1cb49f88b"}}}}