summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/amazons3.php
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-10-31 10:22:20 +0100
committerLukas Reschke <lukas@owncloud.com>2014-10-31 10:22:20 +0100
commit3bc748d43ff5b2f603064fa41a29e909f6d83459 (patch)
treec09f0294e04451aafa60ac9c4b983e34a4bf1003 /apps/files_external/lib/amazons3.php
parentaeb9e172a98eeee26c4e3141b863c5ad44ff13ab (diff)
parent496b62f2eb74a7fb739171af10adb54484b5f583 (diff)
downloadnextcloud-server-3bc748d43ff5b2f603064fa41a29e909f6d83459.tar.gz
nextcloud-server-3bc748d43ff5b2f603064fa41a29e909f6d83459.zip
Merge pull request #11614 from owncloud/fix_files_external_s3_storage_id_migration
fix files_external storage id migration
Diffstat (limited to 'apps/files_external/lib/amazons3.php')
-rw-r--r--apps/files_external/lib/amazons3.php23
1 files changed, 20 insertions, 3 deletions
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php
index 77c5f82d539..a3fe183f30e 100644
--- a/apps/files_external/lib/amazons3.php
+++ b/apps/files_external/lib/amazons3.php
@@ -123,11 +123,28 @@ class AmazonS3 extends \OC\Files\Storage\Common {
* @param array $params
*/
public function updateLegacyId (array $params) {
+ $oldId = 'amazon::' . $params['key'] . md5($params['secret']);
+
+ // find by old id or bucket
$stmt = \OC::$server->getDatabaseConnection()->prepare(
- 'UPDATE `*PREFIX*storages` SET `id` = ? WHERE `id` = ?'
+ 'SELECT `numeric_id`, `id` FROM `*PREFIX*storages` WHERE `id` IN (?, ?)'
);
- $oldId = 'amazon::' . $params['key'] . md5($params['secret']);
- $stmt->execute(array($this->id, $oldId));
+ $stmt->execute(array($oldId, $this->id));
+ while ($row = $stmt->fetch()) {
+ $storages[$row['id']] = $row['numeric_id'];
+ }
+
+ if (isset($storages[$this->id]) && isset($storages[$oldId])) {
+ // if both ids exist, delete the old storage and corresponding filecache entries
+ \OC\Files\Cache\Storage::remove($oldId);
+ } else if (isset($storages[$oldId])) {
+ // if only the old id exists do an update
+ $stmt = \OC::$server->getDatabaseConnection()->prepare(
+ 'UPDATE `*PREFIX*storages` SET `id` = ? WHERE `id` = ?'
+ );
+ $stmt->execute(array($this->id, $oldId));
+ }
+ // only the bucket based id may exist, do nothing
}
/**