{"action":"created","comment":{"url":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls/comments/29532559","id":29532559,"diff_hunk":"@@ -398,21 +440,47 @@ public string DownloadBook(string storageKeyOfBookFolder, string pathToDestinati\n \t\t\t\tvar destinationPath = Path.Combine(pathToDestinationParentDirectory, Path.GetFileName(children[0]));\n \n \t\t\t\t//clear out anything exisitng on our target\n+\t\t\t\tvar didDelete = false;\n \t\t\t\tif (Directory.Exists(destinationPath))\n \t\t\t\t{\n-\t\t\t\t\tDirectory.Delete(destinationPath, true);\n+\t\t\t\t\ttry\n+\t\t\t\t\t{\n+\t\t\t\t\t\tDirectory.Delete(destinationPath, true);\n+\t\t\t\t\t\tdidDelete = true;\n+\t\t\t\t\t}\n+\t\t\t\t\tcatch (IOException)\n+\t\t\t\t\t{\n+\t\t\t\t\t\t// can't delete it...see if we can copy into it.\n+\t\t\t\t\t}\n \t\t\t\t}\n \n \t\t\t\t//if we're on the same volume, we can just move it. Else copy it.\n \t\t\t\t// It's important that books appear as nearly complete as possible, because a file watcher will very soon add the new\n \t\t\t\t// book to the list of downloaded books the user can make new ones from, once it appears in the target directory.\n-\t\t\t\tif (PathUtilities.PathsAreOnSameVolume(pathToDestinationParentDirectory, tempDestination.FolderPath))\n+\t\t\t\tbool done = false;\n+\t\t\t\tif (didDelete && PathUtilities.PathsAreOnSameVolume(pathToDestinationParentDirectory, tempDestination.FolderPath))\n \t\t\t\t{\n-\t\t\t\t\tDirectory.Move(children[0], destinationPath);\n+\t\t\t\t\ttry\n+\t\t\t\t\t{\n+\t\t\t\t\t\tDirectory.Move(children[0], destinationPath);\n+\t\t\t\t\t\tdone = true;\n+\t\t\t\t\t}\n+\t\t\t\t\tcatch (IOException)\n+\t\t\t\t\t{\n+\t\t\t\t\t\t// If moving didn't work we'll just try copying\n+\t\t\t\t\t}\n+\t\t\t\t\tcatch (UnauthorizedAccessException)\n+\t\t\t\t\t{ }\n+\n \t\t\t\t}\n-\t\t\t\telse\n+\t\t\t\tif (!done)\n+\t\t\t\t\tdone = CopyDirectory(children[0], destinationPath);\n+\t\t\t\tif (!done)\n \t\t\t\t{\n-\t\t\t\t\tCopyDirectory(children[0], destinationPath);\n+\t\t\t\t\tvar msg = LocalizationManager.GetString(\"Download.CopyFailed\",\n+\t\t\t\t\t\t\"Bloom downloaded your book but had problems copying it to the bloom library. Possibly you already have a version of this book and some program is using it. You may need to restart your computer and download it again.\");\n+\t\t\t\t\tvar caption = LocalizationManager.GetString(\"Download.Incomplete\", \"Download incomplete\");\n+\t\t\t\t\tMessageBox.Show(null, msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);","path":"src/BloomExe/WebLibraryIntegration/BloomS3Client.cs","position":null,"original_position":124,"commit_id":"15d72dd313215f133074edbb5326dfdc26a62e60","original_commit_id":"e12dae2b738f704331d3ab498bd5c56f26b45821","user":{"login":"JohnThomson","id":1360521,"avatar_url":"https://avatars.githubusercontent.com/u/1360521?v=3","gravatar_id":"","url":"https://api.github.com/users/JohnThomson","html_url":"https://github.com/JohnThomson","followers_url":"https://api.github.com/users/JohnThomson/followers","following_url":"https://api.github.com/users/JohnThomson/following{/other_user}","gists_url":"https://api.github.com/users/JohnThomson/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnThomson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnThomson/subscriptions","organizations_url":"https://api.github.com/users/JohnThomson/orgs","repos_url":"https://api.github.com/users/JohnThomson/repos","events_url":"https://api.github.com/users/JohnThomson/events{/privacy}","received_events_url":"https://api.github.com/users/JohnThomson/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2015-05-01T20:49:06Z","updated_at":"2015-05-01T20:49:06Z","html_url":"https://github.com/BloomBooks/BloomDesktop/pull/445#discussion_r29532559","pull_request_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls/445","_links":{"self":{"href":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls/comments/29532559"},"html":{"href":"https://github.com/BloomBooks/BloomDesktop/pull/445#discussion_r29532559"},"pull_request":{"href":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls/445"}}},"pull_request":{"url":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls/445","id":34561789,"html_url":"https://github.com/BloomBooks/BloomDesktop/pull/445","diff_url":"https://github.com/BloomBooks/BloomDesktop/pull/445.diff","patch_url":"https://github.com/BloomBooks/BloomDesktop/pull/445.patch","issue_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/issues/445","number":445,"state":"open","locked":false,"title":"BL-1205, improve handling of locked files on download","user":{"login":"JohnThomson","id":1360521,"avatar_url":"https://avatars.githubusercontent.com/u/1360521?v=3","gravatar_id":"","url":"https://api.github.com/users/JohnThomson","html_url":"https://github.com/JohnThomson","followers_url":"https://api.github.com/users/JohnThomson/followers","following_url":"https://api.github.com/users/JohnThomson/following{/other_user}","gists_url":"https://api.github.com/users/JohnThomson/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnThomson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnThomson/subscriptions","organizations_url":"https://api.github.com/users/JohnThomson/orgs","repos_url":"https://api.github.com/users/JohnThomson/repos","events_url":"https://api.github.com/users/JohnThomson/events{/privacy}","received_events_url":"https://api.github.com/users/JohnThomson/received_events","type":"User","site_admin":false},"body":"- If we can't delete destination directory or move otherwise\r\nfails, try copy.\r\n- If we can't copy a particular file, see if it already exists with\r\nthe right content, and if so count this as success\r\n- If we really can't make the destination directory correct,\r\ncopy all we can, and give a helpful message","created_at":"2015-05-01T19:45:08Z","updated_at":"2015-05-01T20:49:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d7819196635d4a78620003ae95879932773c35c0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls/445/commits","review_comments_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls/445/comments","review_comment_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/issues/445/comments","statuses_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/statuses/15d72dd313215f133074edbb5326dfdc26a62e60","head":{"label":"JohnThomson:handleLockedFilesDownload","ref":"handleLockedFilesDownload","sha":"15d72dd313215f133074edbb5326dfdc26a62e60","user":{"login":"JohnThomson","id":1360521,"avatar_url":"https://avatars.githubusercontent.com/u/1360521?v=3","gravatar_id":"","url":"https://api.github.com/users/JohnThomson","html_url":"https://github.com/JohnThomson","followers_url":"https://api.github.com/users/JohnThomson/followers","following_url":"https://api.github.com/users/JohnThomson/following{/other_user}","gists_url":"https://api.github.com/users/JohnThomson/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnThomson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnThomson/subscriptions","organizations_url":"https://api.github.com/users/JohnThomson/orgs","repos_url":"https://api.github.com/users/JohnThomson/repos","events_url":"https://api.github.com/users/JohnThomson/events{/privacy}","received_events_url":"https://api.github.com/users/JohnThomson/received_events","type":"User","site_admin":false},"repo":{"id":24875741,"name":"BloomDesktop","full_name":"JohnThomson/BloomDesktop","owner":{"login":"JohnThomson","id":1360521,"avatar_url":"https://avatars.githubusercontent.com/u/1360521?v=3","gravatar_id":"","url":"https://api.github.com/users/JohnThomson","html_url":"https://github.com/JohnThomson","followers_url":"https://api.github.com/users/JohnThomson/followers","following_url":"https://api.github.com/users/JohnThomson/following{/other_user}","gists_url":"https://api.github.com/users/JohnThomson/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnThomson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnThomson/subscriptions","organizations_url":"https://api.github.com/users/JohnThomson/orgs","repos_url":"https://api.github.com/users/JohnThomson/repos","events_url":"https://api.github.com/users/JohnThomson/events{/privacy}","received_events_url":"https://api.github.com/users/JohnThomson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JohnThomson/BloomDesktop","description":"This is not the official repo for Bloom Desktop! It is intended only to contain my personal pull requests. Bloom Desktop is a hybrid c#/javascript/html/css Windows application that dramatically \"lowers the bar\" for language communities who want books in their own languages. Bloom delivers a low-training, high-output system where mother tongue speakers and their advocates work together to foster both community authorship and access to external material in the vernacular. \\n","fork":true,"url":"https://api.github.com/repos/JohnThomson/BloomDesktop","forks_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/forks","keys_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/teams","hooks_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/hooks","issue_events_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/issues/events{/number}","events_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/events","assignees_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/assignees{/user}","branches_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/branches{/branch}","tags_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/tags","blobs_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/git/refs{/sha}","trees_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/statuses/{sha}","languages_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/languages","stargazers_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/stargazers","contributors_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/contributors","subscribers_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/subscribers","subscription_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/subscription","commits_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/commits{/sha}","git_commits_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/git/commits{/sha}","comments_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/comments{/number}","issue_comment_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/issues/comments{/number}","contents_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/contents/{+path}","compare_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/merges","archive_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/downloads","issues_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/issues{/number}","pulls_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/pulls{/number}","milestones_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/milestones{/number}","notifications_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/labels{/name}","releases_url":"https://api.github.com/repos/JohnThomson/BloomDesktop/releases{/id}","created_at":"2014-10-07T03:42:15Z","updated_at":"2015-03-24T18:27:09Z","pushed_at":"2015-05-01T20:48:36Z","git_url":"git://github.com/JohnThomson/BloomDesktop.git","ssh_url":"git@github.com:JohnThomson/BloomDesktop.git","clone_url":"https://github.com/JohnThomson/BloomDesktop.git","svn_url":"https://github.com/JohnThomson/BloomDesktop","homepage":"http://bloomlibrary.org/","size":43750,"stargazers_count":0,"watchers_count":0,"language":"C#","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":"master"}},"base":{"label":"BloomBooks:master","ref":"master","sha":"ecc307bf93937ec9cc932f2b2a86707e84dbbdcc","user":{"login":"BloomBooks","id":5853716,"avatar_url":"https://avatars.githubusercontent.com/u/5853716?v=3","gravatar_id":"","url":"https://api.github.com/users/BloomBooks","html_url":"https://github.com/BloomBooks","followers_url":"https://api.github.com/users/BloomBooks/followers","following_url":"https://api.github.com/users/BloomBooks/following{/other_user}","gists_url":"https://api.github.com/users/BloomBooks/gists{/gist_id}","starred_url":"https://api.github.com/users/BloomBooks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BloomBooks/subscriptions","organizations_url":"https://api.github.com/users/BloomBooks/orgs","repos_url":"https://api.github.com/users/BloomBooks/repos","events_url":"https://api.github.com/users/BloomBooks/events{/privacy}","received_events_url":"https://api.github.com/users/BloomBooks/received_events","type":"Organization","site_admin":false},"repo":{"id":14133680,"name":"BloomDesktop","full_name":"BloomBooks/BloomDesktop","owner":{"login":"BloomBooks","id":5853716,"avatar_url":"https://avatars.githubusercontent.com/u/5853716?v=3","gravatar_id":"","url":"https://api.github.com/users/BloomBooks","html_url":"https://github.com/BloomBooks","followers_url":"https://api.github.com/users/BloomBooks/followers","following_url":"https://api.github.com/users/BloomBooks/following{/other_user}","gists_url":"https://api.github.com/users/BloomBooks/gists{/gist_id}","starred_url":"https://api.github.com/users/BloomBooks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BloomBooks/subscriptions","organizations_url":"https://api.github.com/users/BloomBooks/orgs","repos_url":"https://api.github.com/users/BloomBooks/repos","events_url":"https://api.github.com/users/BloomBooks/events{/privacy}","received_events_url":"https://api.github.com/users/BloomBooks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BloomBooks/BloomDesktop","description":"Bloom Desktop is a hybrid c#/javascript/html/css Windows application that dramatically \"lowers the bar\" for language communities who want books in their own languages. Bloom delivers a low-training, high-output system where mother tongue speakers and their advocates work together to foster both community authorship and access to external material in the vernacular.","fork":false,"url":"https://api.github.com/repos/BloomBooks/BloomDesktop","forks_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/forks","keys_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/teams","hooks_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/hooks","issue_events_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/issues/events{/number}","events_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/events","assignees_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/assignees{/user}","branches_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/branches{/branch}","tags_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/tags","blobs_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/git/refs{/sha}","trees_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/statuses/{sha}","languages_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/languages","stargazers_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/stargazers","contributors_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/contributors","subscribers_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/subscribers","subscription_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/subscription","commits_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/commits{/sha}","git_commits_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/git/commits{/sha}","comments_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/comments{/number}","issue_comment_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/issues/comments{/number}","contents_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/contents/{+path}","compare_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/merges","archive_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/downloads","issues_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/issues{/number}","pulls_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls{/number}","milestones_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/milestones{/number}","notifications_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/labels{/name}","releases_url":"https://api.github.com/repos/BloomBooks/BloomDesktop/releases{/id}","created_at":"2013-11-05T06:12:57Z","updated_at":"2015-05-01T20:35:55Z","pushed_at":"2015-05-01T20:48:37Z","git_url":"git://github.com/BloomBooks/BloomDesktop.git","ssh_url":"git@github.com:BloomBooks/BloomDesktop.git","clone_url":"https://github.com/BloomBooks/BloomDesktop.git","svn_url":"https://github.com/BloomBooks/BloomDesktop","homepage":"http://bloomlibrary.org/","size":61966,"stargazers_count":5,"watchers_count":5,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":7,"forks":10,"open_issues":7,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls/445"},"html":{"href":"https://github.com/BloomBooks/BloomDesktop/pull/445"},"issue":{"href":"https://api.github.com/repos/BloomBooks/BloomDesktop/issues/445"},"comments":{"href":"https://api.github.com/repos/BloomBooks/BloomDesktop/issues/445/comments"},"review_comments":{"href":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls/445/comments"},"review_comment":{"href":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BloomBooks/BloomDesktop/pulls/445/commits"},"statuses":{"href":"https://api.github.com/repos/BloomBooks/BloomDesktop/statuses/15d72dd313215f133074edbb5326dfdc26a62e60"}}}}