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-17 10:58:53 +0300
committerVincent Petry <pvince81@owncloud.com>2016-08-17 15:24:36 +0300
commitaea66fabf41399044328d3f02921911e3f764813 (patch)
tree89450ee573c7070305e2231213a47bb94962c941 /lib
parent4765f5b214ca5d4030be9abafafe56e7b32f986a (diff)
Improve regexp to detect duplicate folders when repairing unmerged shares
Diffstat (limited to 'lib')
-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