{"action":"created","issue":{"url":"https://api.github.com/repos/owncloud/core/issues/14580","labels_url":"https://api.github.com/repos/owncloud/core/issues/14580/labels{/name}","comments_url":"https://api.github.com/repos/owncloud/core/issues/14580/comments","events_url":"https://api.github.com/repos/owncloud/core/issues/14580/events","html_url":"https://github.com/owncloud/core/pull/14580","id":59249859,"number":14580,"title":"\"Integrity constraint violation\" when sharing the same item twice with the same user","user":{"login":"nickvergessen","id":213943,"avatar_url":"https://avatars.githubusercontent.com/u/213943?v=3","gravatar_id":"","url":"https://api.github.com/users/nickvergessen","html_url":"https://github.com/nickvergessen","followers_url":"https://api.github.com/users/nickvergessen/followers","following_url":"https://api.github.com/users/nickvergessen/following{/other_user}","gists_url":"https://api.github.com/users/nickvergessen/gists{/gist_id}","starred_url":"https://api.github.com/users/nickvergessen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickvergessen/subscriptions","organizations_url":"https://api.github.com/users/nickvergessen/orgs","repos_url":"https://api.github.com/users/nickvergessen/repos","events_url":"https://api.github.com/users/nickvergessen/events{/privacy}","received_events_url":"https://api.github.com/users/nickvergessen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/owncloud/core/labels/8.1%20Bugfixing%20Shortlist","name":"8.1 Bugfixing Shortlist","color":"009800"},{"url":"https://api.github.com/repos/owncloud/core/labels/Backport-Request","name":"Backport-Request","color":"006b75"},{"url":"https://api.github.com/repos/owncloud/core/labels/p1-urgent","name":"p1-urgent","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/owncloud/core/milestones/31","html_url":"https://github.com/owncloud/core/milestones/8.1-current","labels_url":"https://api.github.com/repos/owncloud/core/milestones/31/labels","id":912160,"number":31,"title":"8.1-current","description":"","creator":{"login":"MorrisJobke","id":245432,"avatar_url":"https://avatars.githubusercontent.com/u/245432?v=3","gravatar_id":"","url":"https://api.github.com/users/MorrisJobke","html_url":"https://github.com/MorrisJobke","followers_url":"https://api.github.com/users/MorrisJobke/followers","following_url":"https://api.github.com/users/MorrisJobke/following{/other_user}","gists_url":"https://api.github.com/users/MorrisJobke/gists{/gist_id}","starred_url":"https://api.github.com/users/MorrisJobke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MorrisJobke/subscriptions","organizations_url":"https://api.github.com/users/MorrisJobke/orgs","repos_url":"https://api.github.com/users/MorrisJobke/repos","events_url":"https://api.github.com/users/MorrisJobke/events{/privacy}","received_events_url":"https://api.github.com/users/MorrisJobke/received_events","type":"User","site_admin":false},"open_issues":351,"closed_issues":226,"state":"open","created_at":"2014-12-22T12:04:01Z","updated_at":"2015-03-02T11:27:24Z","due_on":"2015-04-02T22:00:00Z","closed_at":null},"comments":8,"created_at":"2015-02-27T15:23:41Z","updated_at":"2015-03-02T11:29:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/owncloud/core/pulls/14580","html_url":"https://github.com/owncloud/core/pull/14580","diff_url":"https://github.com/owncloud/core/pull/14580.diff","patch_url":"https://github.com/owncloud/core/pull/14580.patch"},"body":"The problem is, we try to create the same mount point twice. This PR prevents the SQL error that was triggered previously:\r\n```\r\nserver can not add remote share, An exception occurred while executing '\r\nINSERT INTO `oc_share_external`\r\n\t(`remote`, `share_token`, `password`, `name`, `owner`, `user`, `mountpoint`, `mountpoint_hash`, `accepted`, `remote_id`)\r\n\tVALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'\r\nwith params\r\n[\\\"http:\\\\\\/\\\\\\/localhost\\\\\\/ownCloud\\\\\\/Master\\\\\\/\\\", \\\"blablub\\\", \\\"\\\", \\\"\\\\\\/Peace\\\", \\\"nickv\\\", \\\"user2\\\", \\\"\\\\\\/Peace\\\", \\\"17a857e51e016141bf57b37e9ad43819\\\", 0, 88]:\r\n\r\nSQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'user2-17a857e51e016141bf57b37e9ad43819' for key 'sh_external_mp'\r\n```\r\n\r\nHOWEVER, this means, that 2 people can NOT share a folder `test/` with the same person, until that person accepted/denied one of those shares. The problem is, that the ` (\\d+)` solution only considers existing files. [*guessing from here on*] But until the user accepts the share, the mount point does not exist and therefor the ` (\\d+)` is not increased.\r\n\r\nThis also leads to the assumption, that if the user creates a folder with the same name, or receives a local share with the same name, prior to accepting the share, :see_no_evil: things will happen?!\r\n\r\nUnluckily @schiesbn is not available atm, so I don't know who can help here? @PVince81 @DeepDiver1975 @icewind1991 ?\r\n\r\n\r\n## Broken Scenarios\r\n\r\n### Local folder\r\n1. Open two windows with 2 users on the same instance\r\n2. Send a S2S share a folder1 from user1 to user2\r\n3. Create folder1 as user2 and create a file in it\r\n4. Refresh the page as user2 so the S2S popup shows up and accept the share\r\n5. Local file is invisible\r\n\r\n### Local share\r\n1. Open two windows with 2 users on the same instance\r\n2. Send a S2S share a folder1 from user1 to user2\r\n3. Share a `folder2/folder1` from user1 to user2 with a local share\r\n4. Refresh the page as user2, see the local shared folder1 in the background and the S2S popup in fornt and accept the share\r\n5. Local share is invisible\r\n\r\n### Mount point\r\n1. Open two windows with 2 users on the same instance\r\n2. Send a S2S share a folder1 from user1 to user2\r\n3. Mount something as folder1 for user2\r\n4. Refresh the page as user2 so the S2S popup shows up and accept the share\r\n5. Mount point is invisible\r\n\r\n### Mount point\r\n1. Open two windows with 2 users on the same instance\r\n2. Send a S2S share a folder1 from user1 to user2\r\n3. Send a S2S share a folder2/folder1 from user1 to user2\r\n4. Second share fails"},"comment":{"url":"https://api.github.com/repos/owncloud/core/issues/comments/76696703","html_url":"https://github.com/owncloud/core/pull/14580#issuecomment-76696703","issue_url":"https://api.github.com/repos/owncloud/core/issues/14580","id":76696703,"user":{"login":"scrutinizer-notifier","id":6398257,"avatar_url":"https://avatars.githubusercontent.com/u/6398257?v=3","gravatar_id":"","url":"https://api.github.com/users/scrutinizer-notifier","html_url":"https://github.com/scrutinizer-notifier","followers_url":"https://api.github.com/users/scrutinizer-notifier/followers","following_url":"https://api.github.com/users/scrutinizer-notifier/following{/other_user}","gists_url":"https://api.github.com/users/scrutinizer-notifier/gists{/gist_id}","starred_url":"https://api.github.com/users/scrutinizer-notifier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scrutinizer-notifier/subscriptions","organizations_url":"https://api.github.com/users/scrutinizer-notifier/orgs","repos_url":"https://api.github.com/users/scrutinizer-notifier/repos","events_url":"https://api.github.com/users/scrutinizer-notifier/events{/privacy}","received_events_url":"https://api.github.com/users/scrutinizer-notifier/received_events","type":"User","site_admin":false},"created_at":"2015-03-02T11:29:27Z","updated_at":"2015-03-02T11:29:27Z","body":"The [inspection](https://scrutinizer-ci.com/g/owncloud/core/inspections/371c5aaf-3233-41bc-a333-3c202b536416) completed: **2 new issues, 4 updated code elements**"}}