Skip to content
Snippets Groups Projects
Commit 69a3d8eb authored by Jörn Friedrich Dreyer's avatar Jörn Friedrich Dreyer
Browse files

fix files_external storage id migration

parent ea3fc401
No related branches found
No related tags found
No related merge requests found
...@@ -123,11 +123,28 @@ class AmazonS3 extends \OC\Files\Storage\Common { ...@@ -123,11 +123,28 @@ class AmazonS3 extends \OC\Files\Storage\Common {
* @param array $params * @param array $params
*/ */
public function updateLegacyId (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( $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($oldId, $this->id));
$stmt->execute(array($this->id, $oldId)); 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
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment