Skip to content
Snippets Groups Projects
Commit 8cfa618d authored by Bart Visscher's avatar Bart Visscher
Browse files

Catch exceptions in upgrading files_sharing, skip the errors for now

parent 11bdc8ba
Branches
No related tags found
No related merge requests found
<?php <?php
$installedVersion = OCP\Config::getAppValue('files_sharing', 'installed_version'); $installedVersion = OCP\Config::getAppValue('files_sharing', 'installed_version');
if (version_compare($installedVersion, '0.3', '<')) { if (version_compare($installedVersion, '0.3', '<')) {
$update_error = false;
$query = OCP\DB::prepare('SELECT * FROM `*PREFIX*sharing`'); $query = OCP\DB::prepare('SELECT * FROM `*PREFIX*sharing`');
$result = $query->execute(); $result = $query->execute();
$groupShares = array(); $groupShares = array();
...@@ -38,8 +39,17 @@ if (version_compare($installedVersion, '0.3', '<')) { ...@@ -38,8 +39,17 @@ if (version_compare($installedVersion, '0.3', '<')) {
$shareWith = $row['uid_shared_with']; $shareWith = $row['uid_shared_with'];
} }
OC_User::setUserId($row['uid_owner']); OC_User::setUserId($row['uid_owner']);
try {
OCP\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions); OCP\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions);
} }
catch (Exception $e) {
$update_error = true;
echo 'Skipping sharing "'.$row['source'].'" to "'.$shareWith.'" (error is "'.$e->getMessage().'")<br/>';
}
}
}
if ($update_error) {
throw new Exception('There were some problems upgrading the sharing of files');
} }
// NOTE: Let's drop the table after more testing // NOTE: Let's drop the table after more testing
// $query = OCP\DB::prepare('DROP TABLE `*PREFIX*sharing`'); // $query = OCP\DB::prepare('DROP TABLE `*PREFIX*sharing`');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment