diff options
author | Tom Needham <needham.thomas@gmail.com> | 2012-10-28 11:16:04 +0000 |
---|---|---|
committer | Tom Needham <needham.thomas@gmail.com> | 2012-10-28 11:16:04 +0000 |
commit | bcdf3a23db6867332232f8c1b69ba3fa394e191a (patch) | |
tree | 20be51b4a2e5f1c7f8bc3a50ca3fb9571e972af3 /apps/files_sharing/appinfo | |
parent | b07944798848bc5196dc75e8d8caea5ca71b0f15 (diff) | |
parent | 22dcd3b6a691c7a245e4d1de30f09bb17efdfceb (diff) | |
download | nextcloud-server-bcdf3a23db6867332232f8c1b69ba3fa394e191a.tar.gz nextcloud-server-bcdf3a23db6867332232f8c1b69ba3fa394e191a.zip |
Merge master into ocs_api
Diffstat (limited to 'apps/files_sharing/appinfo')
-rw-r--r-- | apps/files_sharing/appinfo/info.xml | 2 | ||||
-rw-r--r-- | apps/files_sharing/appinfo/update.php | 32 | ||||
-rw-r--r-- | apps/files_sharing/appinfo/version | 2 |
3 files changed, 31 insertions, 5 deletions
diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml index 6a8fc89adae..a44d0338bb6 100644 --- a/apps/files_sharing/appinfo/info.xml +++ b/apps/files_sharing/appinfo/info.xml @@ -5,7 +5,7 @@ <description>File sharing between users</description> <licence>AGPL</licence> <author>Michael Gapczynski</author> - <require>4</require> + <require>4.9</require> <shipped>true</shipped> <default_enable/> <types> diff --git a/apps/files_sharing/appinfo/update.php b/apps/files_sharing/appinfo/update.php index eabd1167c97..e75c538b150 100644 --- a/apps/files_sharing/appinfo/update.php +++ b/apps/files_sharing/appinfo/update.php @@ -1,9 +1,14 @@ <?php $installedVersion = OCP\Config::getAppValue('files_sharing', 'installed_version'); if (version_compare($installedVersion, '0.3', '<')) { + $update_error = false; $query = OCP\DB::prepare('SELECT * FROM `*PREFIX*sharing`'); $result = $query->execute(); $groupShares = array(); + //we need to set up user backends, otherwise creating the shares will fail with "because user does not exist" + OC_User::useBackend(new OC_User_Database()); + OC_Group::useBackend(new OC_Group_Database()); + OC_App::loadApps(array('authentication')); while ($row = $result->fetchRow()) { $itemSource = OC_FileCache::getId($row['source'], ''); if ($itemSource != -1) { @@ -14,9 +19,9 @@ if (version_compare($installedVersion, '0.3', '<')) { $itemType = 'file'; } if ($row['permissions'] == 0) { - $permissions = OCP\Share::PERMISSION_READ; + $permissions = OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_SHARE; } else { - $permissions = OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_UPDATE; + $permissions = OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_UPDATE | OCP\Share::PERMISSION_SHARE; if ($itemType == 'folder') { $permissions |= OCP\Share::PERMISSION_CREATE; } @@ -38,10 +43,31 @@ if (version_compare($installedVersion, '0.3', '<')) { $shareWith = $row['uid_shared_with']; } OC_User::setUserId($row['uid_owner']); - OCP\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions); + //we need to setup the filesystem for the user, otherwise OC_FileSystem::getRoot will fail and break + OC_Util::setupFS($row['uid_owner']); + try { + OCP\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions); + } + catch (Exception $e) { + $update_error = true; + OCP\Util::writeLog('files_sharing', 'Upgrade Routine: Skipping sharing "'.$row['source'].'" to "'.$shareWith.'" (error is "'.$e->getMessage().'")', OCP\Util::WARN); + } + OC_Util::tearDownFS(); } } + OC_User::setUserId(null); + if ($update_error) { + OCP\Util::writeLog('files_sharing', 'There were some problems upgrading the sharing of files', OCP\Util::ERROR); + } // NOTE: Let's drop the table after more testing // $query = OCP\DB::prepare('DROP TABLE `*PREFIX*sharing`'); // $query->execute(); +} +if (version_compare($installedVersion, '0.3.3', '<')) { + OC_User::useBackend(new OC_User_Database()); + OC_App::loadApps(array('authentication')); + $users = OC_User::getUsers(); + foreach ($users as $user) { + OC_FileCache::delete('Shared', '/'.$user.'/files/'); + } }
\ No newline at end of file diff --git a/apps/files_sharing/appinfo/version b/apps/files_sharing/appinfo/version index 9fc80f937fa..87a0871112f 100644 --- a/apps/files_sharing/appinfo/version +++ b/apps/files_sharing/appinfo/version @@ -1 +1 @@ -0.3.2
\ No newline at end of file +0.3.3
\ No newline at end of file |