Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-08-12 13:06:57 +0300
committerThomas Müller <thomas.mueller@tmit.eu>2016-08-13 18:10:13 +0300
commitd2ad8041250d8fac4841a19cca69137474391c53 (patch)
tree1b9ecceaf1614e093068eb3fcd930b224816f27c /lib
parentf68dd4d821a7c2ab19c0f70c07a0e586b1975cbd (diff)
Fix unmerged shares repair with mixed group and direct shares
Whenever a group share is created after a direct share, the stime order needs to be properly considered in the repair routine, considering that the direct user share is appended to the $subShares array and breaking its order.
Diffstat (limited to 'lib')
-rw-r--r--lib/private/repair/repairunmergedshares.php16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/private/repair/repairunmergedshares.php b/lib/private/repair/repairunmergedshares.php
index 723a153aee3..b9ba5cf0ee5 100644
--- a/lib/private/repair/repairunmergedshares.php
+++ b/lib/private/repair/repairunmergedshares.php
@@ -93,7 +93,7 @@ class RepairUnmergedShares extends BasicEmitter implements \OC\RepairStep {
*/
$query = $this->connection->getQueryBuilder();
$query
- ->select('item_source', 'id', 'file_target', 'permissions', 'parent', 'share_type')
+ ->select('item_source', 'id', 'file_target', 'permissions', 'parent', 'share_type', 'stime')
->from('share')
->where($query->expr()->eq('share_type', $query->createParameter('shareType')))
->andWhere($query->expr()->in('share_with', $query->createParameter('shareWiths')))
@@ -161,13 +161,23 @@ class RepairUnmergedShares extends BasicEmitter implements \OC\RepairStep {
* If no suitable subshare is found, use the least recent group share instead.
*
* @param array $groupShares group share entries
- * @param array $subShares sub share entries, sorted by stime
+ * @param array $subShares sub share entries
*
* @return string chosen target name
*/
private function findBestTargetName($groupShares, $subShares) {
$pickedShare = null;
- // note subShares are sorted by stime from oldest to newest
+ // sort by stime, this also properly sorts the direct user share if any
+ @usort($subShares, function($a, $b) {
+ if ($a['stime'] < $b['stime']) {
+ return -1;
+ } else if ($a['stime'] > $b['stime']) {
+ return 1;
+ }
+
+ return 0;
+ });
+
foreach ($subShares as $subShare) {
// skip entries that have parenthesis with numbers
if (preg_match('/\([0-9]*\)/', $subShare['file_target']) === 1) {