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>2015-01-20 16:25:07 +0300
committerVincent Petry <pvince81@owncloud.com>2015-03-16 18:25:21 +0300
commit5538c2732276e2d1d4b30faf475b41a1e8e3681d (patch)
tree2b8bd81253e4f95956d790bccd0eb008c58c90a2 /lib
parent35abb4d71e049c2c7b244ac346c7f1b9e455d20c (diff)
Do not abort when meeting unfixable legacy storages
Diffstat (limited to 'lib')
-rw-r--r--lib/private/repair/repairlegacystorages.php121
1 files changed, 67 insertions, 54 deletions
diff --git a/lib/private/repair/repairlegacystorages.php b/lib/private/repair/repairlegacystorages.php
index ab123afeca6..f09ca2b5cdd 100644
--- a/lib/private/repair/repairlegacystorages.php
+++ b/lib/private/repair/repairlegacystorages.php
@@ -146,75 +146,88 @@ class RepairLegacyStorages extends BasicEmitter {
$this->connection->beginTransaction();
- try {
- // note: not doing a direct UPDATE with the REPLACE function
- // because regexp search/extract is needed and it is not guaranteed
- // to work on all database types
- $sql = 'SELECT `id`, `numeric_id` FROM `*PREFIX*storages`'
- . ' WHERE `id` LIKE ?'
- . ' ORDER BY `id`';
- $result = $this->connection->executeQuery($sql, array($dataDirId . '%'));
- while ($row = $result->fetch()) {
- $currentId = $row['id'];
- // one entry is the datadir itself
- if ($currentId === $dataDirId) {
- continue;
- }
+ // note: not doing a direct UPDATE with the REPLACE function
+ // because regexp search/extract is needed and it is not guaranteed
+ // to work on all database types
+ $sql = 'SELECT `id`, `numeric_id` FROM `*PREFIX*storages`'
+ . ' WHERE `id` LIKE ?'
+ . ' ORDER BY `id`';
+ $result = $this->connection->executeQuery($sql, array($dataDirId . '%'));
+
+ while ($row = $result->fetch()) {
+ $currentId = $row['id'];
+ // one entry is the datadir itself
+ if ($currentId === $dataDirId) {
+ continue;
+ }
+ try {
if ($this->fixLegacyStorage($currentId, (int)$row['numeric_id'])) {
$count++;
}
}
+ catch (\OC\RepairException $e) {
+ $this->emit(
+ '\OC\Repair',
+ 'warning',
+ array('Could not repair legacy storage ' . $currentId . ' automatically.')
+ );
+ }
+ }
- // check for md5 ids, not in the format "prefix::"
- $sql = 'SELECT COUNT(*) AS "c" FROM `*PREFIX*storages`'
- . ' WHERE `id` NOT LIKE \'%::%\'';
- $result = $this->connection->executeQuery($sql);
- $row = $result->fetch();
- // find at least one to make sure it's worth
- // querying the user list
- if ((int)$row['c'] > 0) {
- $userManager = \OC_User::getManager();
-
- // use chunks to avoid caching too many users in memory
- $limit = 30;
- $offset = 0;
-
- do {
- // query the next page of users
- $results = $userManager->search('', $limit, $offset);
- $storageIds = array();
- $userIds = array();
- foreach ($results as $uid => $userObject) {
- $storageId = $dataDirId . $uid . '/';
- if (strlen($storageId) <= 64) {
- // skip short storage ids as they were handled in the previous section
- continue;
- }
- $storageIds[$uid] = $storageId;
+ // check for md5 ids, not in the format "prefix::"
+ $sql = 'SELECT COUNT(*) AS "c" FROM `*PREFIX*storages`'
+ . ' WHERE `id` NOT LIKE \'%::%\'';
+ $result = $this->connection->executeQuery($sql);
+ $row = $result->fetch();
+ // find at least one to make sure it's worth
+ // querying the user list
+ if ((int)$row['c'] > 0) {
+ $userManager = \OC_User::getManager();
+
+ // use chunks to avoid caching too many users in memory
+ $limit = 30;
+ $offset = 0;
+
+ do {
+ // query the next page of users
+ $results = $userManager->search('', $limit, $offset);
+ $storageIds = array();
+ $userIds = array();
+ foreach ($results as $uid => $userObject) {
+ $storageId = $dataDirId . $uid . '/';
+ if (strlen($storageId) <= 64) {
+ // skip short storage ids as they were handled in the previous section
+ continue;
}
+ $storageIds[$uid] = $storageId;
+ }
- if (count($storageIds) > 0) {
- // update the storages of these users
- foreach ($storageIds as $uid => $storageId) {
- $numericId = \OC\Files\Cache\Storage::getNumericStorageId($storageId);
+ if (count($storageIds) > 0) {
+ // update the storages of these users
+ foreach ($storageIds as $uid => $storageId) {
+ $numericId = \OC\Files\Cache\Storage::getNumericStorageId($storageId);
+ try {
if (!is_null($numericId) && $this->fixLegacyStorage($storageId, (int)$numericId)) {
$count++;
}
}
+ catch (\OC\RepairException $e) {
+ $this->emit(
+ '\OC\Repair',
+ 'warning',
+ array('Could not repair legacy storage ' . $storageId . ' automatically.')
+ );
+ }
}
- $offset += $limit;
- } while (count($results) >= $limit);
- }
+ }
+ $offset += $limit;
+ } while (count($results) >= $limit);
+ }
- $this->emit('\OC\Repair', 'info', array('Updated ' . $count . ' legacy home storage ids'));
+ $this->emit('\OC\Repair', 'info', array('Updated ' . $count . ' legacy home storage ids'));
- $this->connection->commit();
- }
- catch (\OC\RepairException $e) {
- $this->connection->rollback();
- throw $e;
- }
+ $this->connection->commit();
$this->config->setAppValue('core', 'repairlegacystoragesdone', 'yes');
}