{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls/comments/50280430","id":50280430,"diff_hunk":"@@ -107,14 +111,25 @@ def _orphan_children(self, node, remote_children):\n         locally for which the remote Node has been deleted are explicitly removed\n         from OSFO's auditing and will be ignored.\n         \"\"\"\n-        children_ids = map(lambda c: c.id, remote_children)\n+        children_ids = [c.id for c in remote_children]\n         for record in node.children:\n             if record.id not in children_ids:\n                 Session().delete(record)\n+            else:\n+                remote_child = OSFClient().get_node(record.id)\n+                self._orphan_children(record, remote_child.get_children(lazy=False))\n \n     def _preprocess_node(self, node, *, delete=True):\n         nodes = [node]\n-        remote_node = OSFClient().get_node(node.id)\n+        try:\n+            remote_node = OSFClient().get_node(node.id)\n+        except ClientLoadError as err:\n+            if err.status in (http.client.NOT_FOUND, http.client.GONE):\n+                # cascade should automagically delete children\n+                Session().delete(node)","path":"osfoffline/sync/remote.py","position":57,"original_position":57,"commit_id":"b3481ff5214dace0d4069ea2eef48164985f6297","original_commit_id":"b3481ff5214dace0d4069ea2eef48164985f6297","user":{"login":"abought","id":2957073,"avatar_url":"https://avatars.githubusercontent.com/u/2957073?v=3","gravatar_id":"","url":"https://api.github.com/users/abought","html_url":"https://github.com/abought","followers_url":"https://api.github.com/users/abought/followers","following_url":"https://api.github.com/users/abought/following{/other_user}","gists_url":"https://api.github.com/users/abought/gists{/gist_id}","starred_url":"https://api.github.com/users/abought/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abought/subscriptions","organizations_url":"https://api.github.com/users/abought/orgs","repos_url":"https://api.github.com/users/abought/repos","events_url":"https://api.github.com/users/abought/events{/privacy}","received_events_url":"https://api.github.com/users/abought/received_events","type":"User","site_admin":false},"body":"It appears that calling delete doesn't actually delete from the underlying DB. You may need to use `Session().commit` or `flush` after this to avoid error messages and various other odd behavior.","created_at":"2016-01-20T16:43:28Z","updated_at":"2016-01-20T16:43:28Z","html_url":"https://github.com/CenterForOpenScience/OSF-Offline/pull/134#discussion_r50280430","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls/134","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls/comments/50280430"},"html":{"href":"https://github.com/CenterForOpenScience/OSF-Offline/pull/134#discussion_r50280430"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls/134"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls/134","id":56508869,"html_url":"https://github.com/CenterForOpenScience/OSF-Offline/pull/134","diff_url":"https://github.com/CenterForOpenScience/OSF-Offline/pull/134.diff","patch_url":"https://github.com/CenterForOpenScience/OSF-Offline/pull/134.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/issues/134","number":134,"state":"open","locked":false,"title":"[RFR] Handle remote deletion of resources","user":{"login":"samchrisinger","id":2207561,"avatar_url":"https://avatars.githubusercontent.com/u/2207561?v=3","gravatar_id":"","url":"https://api.github.com/users/samchrisinger","html_url":"https://github.com/samchrisinger","followers_url":"https://api.github.com/users/samchrisinger/followers","following_url":"https://api.github.com/users/samchrisinger/following{/other_user}","gists_url":"https://api.github.com/users/samchrisinger/gists{/gist_id}","starred_url":"https://api.github.com/users/samchrisinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samchrisinger/subscriptions","organizations_url":"https://api.github.com/users/samchrisinger/orgs","repos_url":"https://api.github.com/users/samchrisinger/repos","events_url":"https://api.github.com/users/samchrisinger/events{/privacy}","received_events_url":"https://api.github.com/users/samchrisinger/received_events","type":"User","site_admin":false},"body":"# Purpose\r\n\r\nsee: \r\nhttps://openscience.atlassian.net/browse/OFF-85\r\nhttps://openscience.atlassian.net/browse/OFF-86\r\n\r\ntldr: deleting a project that was synced locally would cause the remote sync loop to hang\r\n\r\n# Changes\r\n\r\n- add ClientLoadError as a generic exception for API requests that fail for some reason\r\n- try/except Node loads in RemoteSyncWorker's#_preprocess_node, and explicitly hander 4XX status codes\r\n- some other cleanup from https://github.com/CenterForOpenScience/OSF-Offline/pull/125, in particular with consolidation/unification of how we shut down workers","created_at":"2016-01-19T18:53:39Z","updated_at":"2016-01-20T16:43:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15058da26618c00a8fca4d9e0460214f0ed1bb1d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls/134/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls/134/comments","review_comment_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/issues/134/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/statuses/b3481ff5214dace0d4069ea2eef48164985f6297","head":{"label":"samchrisinger:feature/remote-delete","ref":"feature/remote-delete","sha":"b3481ff5214dace0d4069ea2eef48164985f6297","user":{"login":"samchrisinger","id":2207561,"avatar_url":"https://avatars.githubusercontent.com/u/2207561?v=3","gravatar_id":"","url":"https://api.github.com/users/samchrisinger","html_url":"https://github.com/samchrisinger","followers_url":"https://api.github.com/users/samchrisinger/followers","following_url":"https://api.github.com/users/samchrisinger/following{/other_user}","gists_url":"https://api.github.com/users/samchrisinger/gists{/gist_id}","starred_url":"https://api.github.com/users/samchrisinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samchrisinger/subscriptions","organizations_url":"https://api.github.com/users/samchrisinger/orgs","repos_url":"https://api.github.com/users/samchrisinger/repos","events_url":"https://api.github.com/users/samchrisinger/events{/privacy}","received_events_url":"https://api.github.com/users/samchrisinger/received_events","type":"User","site_admin":false},"repo":{"id":48767035,"name":"OSF-Offline","full_name":"samchrisinger/OSF-Offline","owner":{"login":"samchrisinger","id":2207561,"avatar_url":"https://avatars.githubusercontent.com/u/2207561?v=3","gravatar_id":"","url":"https://api.github.com/users/samchrisinger","html_url":"https://github.com/samchrisinger","followers_url":"https://api.github.com/users/samchrisinger/followers","following_url":"https://api.github.com/users/samchrisinger/following{/other_user}","gists_url":"https://api.github.com/users/samchrisinger/gists{/gist_id}","starred_url":"https://api.github.com/users/samchrisinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samchrisinger/subscriptions","organizations_url":"https://api.github.com/users/samchrisinger/orgs","repos_url":"https://api.github.com/users/samchrisinger/repos","events_url":"https://api.github.com/users/samchrisinger/events{/privacy}","received_events_url":"https://api.github.com/users/samchrisinger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/samchrisinger/OSF-Offline","description":"Desktop Synchronization for OSF Projects ","fork":true,"url":"https://api.github.com/repos/samchrisinger/OSF-Offline","forks_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/forks","keys_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/teams","hooks_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/hooks","issue_events_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/issues/events{/number}","events_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/events","assignees_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/assignees{/user}","branches_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/branches{/branch}","tags_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/tags","blobs_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/git/refs{/sha}","trees_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/statuses/{sha}","languages_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/languages","stargazers_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/stargazers","contributors_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/contributors","subscribers_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/subscribers","subscription_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/subscription","commits_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/commits{/sha}","git_commits_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/git/commits{/sha}","comments_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/comments{/number}","issue_comment_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/issues/comments{/number}","contents_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/contents/{+path}","compare_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/merges","archive_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/downloads","issues_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/issues{/number}","pulls_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/pulls{/number}","milestones_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/milestones{/number}","notifications_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/labels{/name}","releases_url":"https://api.github.com/repos/samchrisinger/OSF-Offline/releases{/id}","created_at":"2015-12-29T21:01:50Z","updated_at":"2015-12-29T21:01:51Z","pushed_at":"2016-01-19T21:21:46Z","git_url":"git://github.com/samchrisinger/OSF-Offline.git","ssh_url":"git@github.com:samchrisinger/OSF-Offline.git","clone_url":"https://github.com/samchrisinger/OSF-Offline.git","svn_url":"https://github.com/samchrisinger/OSF-Offline","homepage":null,"size":2250,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"CenterForOpenScience:develop","ref":"develop","sha":"e31339b69034cb9a28f5e631d9d84cd4a691ce10","user":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"repo":{"id":37069756,"name":"OSF-Offline","full_name":"CenterForOpenScience/OSF-Offline","owner":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CenterForOpenScience/OSF-Offline","description":"Desktop Synchronization for OSF Projects ","fork":false,"url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline","forks_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/forks","keys_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/teams","hooks_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/hooks","issue_events_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/issues/events{/number}","events_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/events","assignees_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/assignees{/user}","branches_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/branches{/branch}","tags_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/tags","blobs_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/git/refs{/sha}","trees_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/statuses/{sha}","languages_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/languages","stargazers_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/stargazers","contributors_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/contributors","subscribers_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/subscribers","subscription_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/subscription","commits_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/commits{/sha}","git_commits_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/git/commits{/sha}","comments_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/comments{/number}","issue_comment_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/issues/comments{/number}","contents_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/contents/{+path}","compare_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/merges","archive_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/downloads","issues_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/issues{/number}","pulls_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls{/number}","milestones_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/milestones{/number}","notifications_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/labels{/name}","releases_url":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/releases{/id}","created_at":"2015-06-08T13:50:50Z","updated_at":"2016-01-20T11:37:32Z","pushed_at":"2016-01-19T23:23:03Z","git_url":"git://github.com/CenterForOpenScience/OSF-Offline.git","ssh_url":"git@github.com:CenterForOpenScience/OSF-Offline.git","clone_url":"https://github.com/CenterForOpenScience/OSF-Offline.git","svn_url":"https://github.com/CenterForOpenScience/OSF-Offline","homepage":null,"size":2361,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":6,"forks":10,"open_issues":6,"watchers":3,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls/134"},"html":{"href":"https://github.com/CenterForOpenScience/OSF-Offline/pull/134"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/issues/134"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/issues/134/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls/134/comments"},"review_comment":{"href":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/pulls/134/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/OSF-Offline/statuses/b3481ff5214dace0d4069ea2eef48164985f6297"}}}}