{"action":"created","comment":{"url":"https://api.github.com/repos/owncloud/core/pulls/comments/75071361","id":75071361,"diff_hunk":"@@ -149,6 +149,54 @@ private function getSharesWithUser($shareType, $shareWiths) {\n \t}\n \n \t/**\n+\t * Decide on the best target name based on all group shares and subshares,\n+\t * goal is to increase the likeliness that the chosen name matches what\n+\t * the user is expecting.\n+\t *\n+\t * For this, we discard the entries with parenthesis \"(2)\".\n+\t * In case the user also renamed the duplicates to a legitimate name, this logic\n+\t * will still pick the most recent one as it's the one the user is most likely to\n+\t * remember renaming.\n+\t *\n+\t * If no suitable subshare is found, use the least recent group share instead.\n+\t *\n+\t * @param array $groupShares group share entries\n+\t * @param array $subShares sub share entries\n+\t *\n+\t * @return string chosen target name\n+\t */\n+\tprivate function findBestTargetName($groupShares, $subShares) {\n+\t\t$pickedShare = null;\n+\t\t// sort by stime, this also properly sorts the direct user share if any\n+\t\t@usort($subShares, function($a, $b) {\n+\t\t\tif ($a['stime'] < $b['stime']) {\n+\t\t\t\treturn -1;\n+\t\t\t} else if ($a['stime'] > $b['stime']) {\n+\t\t\t\treturn 1;\n+\t\t\t}\n+\n+\t\t\treturn 0;\n+\t\t});\n+\n+\t\tforeach ($subShares as $subShare) {\n+\t\t\t// skip entries that have parenthesis with numbers\n+\t\t\tif (preg_match('/\\([0-9]*\\)/', $subShare['file_target']) === 1) {","path":"lib/private/Repair/RepairUnmergedShares.php","position":44,"original_position":44,"commit_id":"8cca3641603d755ed2da6e4be5fc4748f591e9e2","original_commit_id":"8cca3641603d755ed2da6e4be5fc4748f591e9e2","user":{"login":"jvillafanez","id":1477829,"avatar_url":"https://avatars.githubusercontent.com/u/1477829?v=3","gravatar_id":"","url":"https://api.github.com/users/jvillafanez","html_url":"https://github.com/jvillafanez","followers_url":"https://api.github.com/users/jvillafanez/followers","following_url":"https://api.github.com/users/jvillafanez/following{/other_user}","gists_url":"https://api.github.com/users/jvillafanez/gists{/gist_id}","starred_url":"https://api.github.com/users/jvillafanez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvillafanez/subscriptions","organizations_url":"https://api.github.com/users/jvillafanez/orgs","repos_url":"https://api.github.com/users/jvillafanez/repos","events_url":"https://api.github.com/users/jvillafanez/events{/privacy}","received_events_url":"https://api.github.com/users/jvillafanez/received_events","type":"User","site_admin":false},"body":"After checking how the names are generated, `/\\(\\d+\\)(\\.[^\\.]+)?$/` is a better option. It should match:\r\n* \"filename (1).txt\"\r\n* \"filename (2)\"\r\n* \"filename (1)(2).txt\"\r\n\r\nbut not\r\n* \"filename ().txt\"\r\n* \"filename ()\"\r\n* \"filename (1).\"\r\n* \"filename (1).txt.txt\"\r\n* \"filename (1)..txt\"","created_at":"2016-08-17T07:02:23Z","updated_at":"2016-08-17T07:02:23Z","html_url":"https://github.com/owncloud/core/pull/25812#discussion_r75071361","pull_request_url":"https://api.github.com/repos/owncloud/core/pulls/25812","_links":{"self":{"href":"https://api.github.com/repos/owncloud/core/pulls/comments/75071361"},"html":{"href":"https://github.com/owncloud/core/pull/25812#discussion_r75071361"},"pull_request":{"href":"https://api.github.com/repos/owncloud/core/pulls/25812"}}},"pull_request":{"url":"https://api.github.com/repos/owncloud/core/pulls/25812","id":81438351,"html_url":"https://github.com/owncloud/core/pull/25812","diff_url":"https://github.com/owncloud/core/pull/25812.diff","patch_url":"https://github.com/owncloud/core/pull/25812.patch","issue_url":"https://api.github.com/repos/owncloud/core/issues/25812","number":25812,"state":"open","locked":false,"title":"[stable9.1] Fix unmerged shares repair targetdecision","user":{"login":"PVince81","id":277525,"avatar_url":"https://avatars.githubusercontent.com/u/277525?v=3","gravatar_id":"","url":"https://api.github.com/users/PVince81","html_url":"https://github.com/PVince81","followers_url":"https://api.github.com/users/PVince81/followers","following_url":"https://api.github.com/users/PVince81/following{/other_user}","gists_url":"https://api.github.com/users/PVince81/gists{/gist_id}","starred_url":"https://api.github.com/users/PVince81/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PVince81/subscriptions","organizations_url":"https://api.github.com/users/PVince81/orgs","repos_url":"https://api.github.com/users/PVince81/repos","events_url":"https://api.github.com/users/PVince81/events{/privacy}","received_events_url":"https://api.github.com/users/PVince81/received_events","type":"User","site_admin":false},"body":"Forward port of #25543 (comment)\r\n\r\nWhen repairing unmerged shares, make a better decision on which files_target to use to be closer to what the user expects.\r\n\r\n@owncloud/sharing @DeepDiver1975 \r\n","created_at":"2016-08-16T09:14:15Z","updated_at":"2016-08-17T07:02:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4131533e18baf12de664863d54e8028bf82c3a4a","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/owncloud/core/milestones/90","html_url":"https://github.com/owncloud/core/milestones/9.1.1","labels_url":"https://api.github.com/repos/owncloud/core/milestones/90/labels","id":1857607,"number":90,"title":"9.1.1","description":null,"creator":{"login":"PVince81","id":277525,"avatar_url":"https://avatars.githubusercontent.com/u/277525?v=3","gravatar_id":"","url":"https://api.github.com/users/PVince81","html_url":"https://github.com/PVince81","followers_url":"https://api.github.com/users/PVince81/followers","following_url":"https://api.github.com/users/PVince81/following{/other_user}","gists_url":"https://api.github.com/users/PVince81/gists{/gist_id}","starred_url":"https://api.github.com/users/PVince81/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PVince81/subscriptions","organizations_url":"https://api.github.com/users/PVince81/orgs","repos_url":"https://api.github.com/users/PVince81/repos","events_url":"https://api.github.com/users/PVince81/events{/privacy}","received_events_url":"https://api.github.com/users/PVince81/received_events","type":"User","site_admin":false},"open_issues":212,"closed_issues":47,"state":"open","created_at":"2016-06-30T14:57:55Z","updated_at":"2016-08-16T15:22:13Z","due_on":"2016-08-23T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/owncloud/core/pulls/25812/commits","review_comments_url":"https://api.github.com/repos/owncloud/core/pulls/25812/comments","review_comment_url":"https://api.github.com/repos/owncloud/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/owncloud/core/issues/25812/comments","statuses_url":"https://api.github.com/repos/owncloud/core/statuses/8cca3641603d755ed2da6e4be5fc4748f591e9e2","head":{"label":"owncloud:stable9.1-fix-unmerged-shares-repair-targetdecision","ref":"stable9.1-fix-unmerged-shares-repair-targetdecision","sha":"8cca3641603d755ed2da6e4be5fc4748f591e9e2","user":{"login":"owncloud","id":1645051,"avatar_url":"https://avatars.githubusercontent.com/u/1645051?v=3","gravatar_id":"","url":"https://api.github.com/users/owncloud","html_url":"https://github.com/owncloud","followers_url":"https://api.github.com/users/owncloud/followers","following_url":"https://api.github.com/users/owncloud/following{/other_user}","gists_url":"https://api.github.com/users/owncloud/gists{/gist_id}","starred_url":"https://api.github.com/users/owncloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owncloud/subscriptions","organizations_url":"https://api.github.com/users/owncloud/orgs","repos_url":"https://api.github.com/users/owncloud/repos","events_url":"https://api.github.com/users/owncloud/events{/privacy}","received_events_url":"https://api.github.com/users/owncloud/received_events","type":"Organization","site_admin":false},"repo":{"id":5550552,"name":"core","full_name":"owncloud/core","owner":{"login":"owncloud","id":1645051,"avatar_url":"https://avatars.githubusercontent.com/u/1645051?v=3","gravatar_id":"","url":"https://api.github.com/users/owncloud","html_url":"https://github.com/owncloud","followers_url":"https://api.github.com/users/owncloud/followers","following_url":"https://api.github.com/users/owncloud/following{/other_user}","gists_url":"https://api.github.com/users/owncloud/gists{/gist_id}","starred_url":"https://api.github.com/users/owncloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owncloud/subscriptions","organizations_url":"https://api.github.com/users/owncloud/orgs","repos_url":"https://api.github.com/users/owncloud/repos","events_url":"https://api.github.com/users/owncloud/events{/privacy}","received_events_url":"https://api.github.com/users/owncloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/owncloud/core","description":":cloud: ownCloud web server core (Files, DAV, etc.)","fork":false,"url":"https://api.github.com/repos/owncloud/core","forks_url":"https://api.github.com/repos/owncloud/core/forks","keys_url":"https://api.github.com/repos/owncloud/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/owncloud/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/owncloud/core/teams","hooks_url":"https://api.github.com/repos/owncloud/core/hooks","issue_events_url":"https://api.github.com/repos/owncloud/core/issues/events{/number}","events_url":"https://api.github.com/repos/owncloud/core/events","assignees_url":"https://api.github.com/repos/owncloud/core/assignees{/user}","branches_url":"https://api.github.com/repos/owncloud/core/branches{/branch}","tags_url":"https://api.github.com/repos/owncloud/core/tags","blobs_url":"https://api.github.com/repos/owncloud/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/owncloud/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/owncloud/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/owncloud/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/owncloud/core/statuses/{sha}","languages_url":"https://api.github.com/repos/owncloud/core/languages","stargazers_url":"https://api.github.com/repos/owncloud/core/stargazers","contributors_url":"https://api.github.com/repos/owncloud/core/contributors","subscribers_url":"https://api.github.com/repos/owncloud/core/subscribers","subscription_url":"https://api.github.com/repos/owncloud/core/subscription","commits_url":"https://api.github.com/repos/owncloud/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/owncloud/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/owncloud/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/owncloud/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/owncloud/core/contents/{+path}","compare_url":"https://api.github.com/repos/owncloud/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/owncloud/core/merges","archive_url":"https://api.github.com/repos/owncloud/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/owncloud/core/downloads","issues_url":"https://api.github.com/repos/owncloud/core/issues{/number}","pulls_url":"https://api.github.com/repos/owncloud/core/pulls{/number}","milestones_url":"https://api.github.com/repos/owncloud/core/milestones{/number}","notifications_url":"https://api.github.com/repos/owncloud/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/owncloud/core/labels{/name}","releases_url":"https://api.github.com/repos/owncloud/core/releases{/id}","deployments_url":"https://api.github.com/repos/owncloud/core/deployments","created_at":"2012-08-25T10:32:48Z","updated_at":"2016-08-17T07:01:09Z","pushed_at":"2016-08-17T06:43:33Z","git_url":"git://github.com/owncloud/core.git","ssh_url":"git@github.com:owncloud/core.git","clone_url":"https://github.com/owncloud/core.git","svn_url":"https://github.com/owncloud/core","homepage":"https://owncloud.org/","size":327669,"stargazers_count":4756,"watchers_count":4756,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1560,"mirror_url":null,"open_issues_count":1837,"forks":1560,"open_issues":1837,"watchers":4756,"default_branch":"master"}},"base":{"label":"owncloud:stable9.1","ref":"stable9.1","sha":"c492277cf1c27c9585fbed949d6922714538f94e","user":{"login":"owncloud","id":1645051,"avatar_url":"https://avatars.githubusercontent.com/u/1645051?v=3","gravatar_id":"","url":"https://api.github.com/users/owncloud","html_url":"https://github.com/owncloud","followers_url":"https://api.github.com/users/owncloud/followers","following_url":"https://api.github.com/users/owncloud/following{/other_user}","gists_url":"https://api.github.com/users/owncloud/gists{/gist_id}","starred_url":"https://api.github.com/users/owncloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owncloud/subscriptions","organizations_url":"https://api.github.com/users/owncloud/orgs","repos_url":"https://api.github.com/users/owncloud/repos","events_url":"https://api.github.com/users/owncloud/events{/privacy}","received_events_url":"https://api.github.com/users/owncloud/received_events","type":"Organization","site_admin":false},"repo":{"id":5550552,"name":"core","full_name":"owncloud/core","owner":{"login":"owncloud","id":1645051,"avatar_url":"https://avatars.githubusercontent.com/u/1645051?v=3","gravatar_id":"","url":"https://api.github.com/users/owncloud","html_url":"https://github.com/owncloud","followers_url":"https://api.github.com/users/owncloud/followers","following_url":"https://api.github.com/users/owncloud/following{/other_user}","gists_url":"https://api.github.com/users/owncloud/gists{/gist_id}","starred_url":"https://api.github.com/users/owncloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/owncloud/subscriptions","organizations_url":"https://api.github.com/users/owncloud/orgs","repos_url":"https://api.github.com/users/owncloud/repos","events_url":"https://api.github.com/users/owncloud/events{/privacy}","received_events_url":"https://api.github.com/users/owncloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/owncloud/core","description":":cloud: ownCloud web server core (Files, DAV, etc.)","fork":false,"url":"https://api.github.com/repos/owncloud/core","forks_url":"https://api.github.com/repos/owncloud/core/forks","keys_url":"https://api.github.com/repos/owncloud/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/owncloud/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/owncloud/core/teams","hooks_url":"https://api.github.com/repos/owncloud/core/hooks","issue_events_url":"https://api.github.com/repos/owncloud/core/issues/events{/number}","events_url":"https://api.github.com/repos/owncloud/core/events","assignees_url":"https://api.github.com/repos/owncloud/core/assignees{/user}","branches_url":"https://api.github.com/repos/owncloud/core/branches{/branch}","tags_url":"https://api.github.com/repos/owncloud/core/tags","blobs_url":"https://api.github.com/repos/owncloud/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/owncloud/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/owncloud/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/owncloud/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/owncloud/core/statuses/{sha}","languages_url":"https://api.github.com/repos/owncloud/core/languages","stargazers_url":"https://api.github.com/repos/owncloud/core/stargazers","contributors_url":"https://api.github.com/repos/owncloud/core/contributors","subscribers_url":"https://api.github.com/repos/owncloud/core/subscribers","subscription_url":"https://api.github.com/repos/owncloud/core/subscription","commits_url":"https://api.github.com/repos/owncloud/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/owncloud/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/owncloud/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/owncloud/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/owncloud/core/contents/{+path}","compare_url":"https://api.github.com/repos/owncloud/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/owncloud/core/merges","archive_url":"https://api.github.com/repos/owncloud/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/owncloud/core/downloads","issues_url":"https://api.github.com/repos/owncloud/core/issues{/number}","pulls_url":"https://api.github.com/repos/owncloud/core/pulls{/number}","milestones_url":"https://api.github.com/repos/owncloud/core/milestones{/number}","notifications_url":"https://api.github.com/repos/owncloud/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/owncloud/core/labels{/name}","releases_url":"https://api.github.com/repos/owncloud/core/releases{/id}","deployments_url":"https://api.github.com/repos/owncloud/core/deployments","created_at":"2012-08-25T10:32:48Z","updated_at":"2016-08-17T07:01:09Z","pushed_at":"2016-08-17T06:43:33Z","git_url":"git://github.com/owncloud/core.git","ssh_url":"git@github.com:owncloud/core.git","clone_url":"https://github.com/owncloud/core.git","svn_url":"https://github.com/owncloud/core","homepage":"https://owncloud.org/","size":327669,"stargazers_count":4756,"watchers_count":4756,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1560,"mirror_url":null,"open_issues_count":1837,"forks":1560,"open_issues":1837,"watchers":4756,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/owncloud/core/pulls/25812"},"html":{"href":"https://github.com/owncloud/core/pull/25812"},"issue":{"href":"https://api.github.com/repos/owncloud/core/issues/25812"},"comments":{"href":"https://api.github.com/repos/owncloud/core/issues/25812/comments"},"review_comments":{"href":"https://api.github.com/repos/owncloud/core/pulls/25812/comments"},"review_comment":{"href":"https://api.github.com/repos/owncloud/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/owncloud/core/pulls/25812/commits"},"statuses":{"href":"https://api.github.com/repos/owncloud/core/statuses/8cca3641603d755ed2da6e4be5fc4748f591e9e2"}}}}
{"actor":{"display_login":"jvillafanez"}}