Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
69a3d8eb
Commit
69a3d8eb
authored
Oct 16, 2014
by
Jörn Friedrich Dreyer
Browse files
fix files_external storage id migration
parent
ea3fc401
Changes
1
Hide whitespace changes
Inline
Side-by-side
apps/files_external/lib/amazons3.php
View file @
69a3d8eb
...
...
@@ -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
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment