summaryrefslogtreecommitdiffstats
path: root/lib/private/Repair
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-08-17 09:58:53 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-08-17 15:31:47 +0200
commitdf9b509ed33ef6e3041b76b4b7ce1b22c7d81fcc (patch)
tree69c5a7dccdc784dafa7d829c9e189d0c623da296 /lib/private/Repair
parent7a2d25fab4bb2b452b513e41adda4dec68e81bbe (diff)
downloadnextcloud-server-df9b509ed33ef6e3041b76b4b7ce1b22c7d81fcc.tar.gz
nextcloud-server-df9b509ed33ef6e3041b76b4b7ce1b22c7d81fcc.zip
Improve regexp to detect duplicate folders when repairing unmerged shares
Diffstat (limited to 'lib/private/Repair')
-rw-r--r--lib/private/Repair/RepairUnmergedShares.php14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/private/Repair/RepairUnmergedShares.php b/lib/private/Repair/RepairUnmergedShares.php
index c29de87c4e8..d57bc3779f8 100644
--- a/lib/private/Repair/RepairUnmergedShares.php
+++ b/lib/private/Repair/RepairUnmergedShares.php
@@ -148,6 +148,10 @@ class RepairUnmergedShares implements IRepairStep {
return $groupedShares;
}
+ private function isPotentialDuplicateName($name) {
+ return (preg_match('/\(\d+\)(\.[^\.]+)?$/', $name) === 1);
+ }
+
/**
* Decide on the best target name based on all group shares and subshares,
* goal is to increase the likeliness that the chosen name matches what
@@ -169,18 +173,12 @@ class RepairUnmergedShares implements IRepairStep {
$pickedShare = null;
// 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;
+ return ((int)$a['stime'] - (int)$b['stime']);
});
foreach ($subShares as $subShare) {
// skip entries that have parenthesis with numbers
- if (preg_match('/\([0-9]*\)/', $subShare['file_target']) === 1) {
+ if ($this->isPotentialDuplicateName($subShare['file_target'])) {
continue;
}
// pick any share found that would match, the last being the most recent