diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-09-22 14:28:14 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-09-22 14:28:14 +0200 |
commit | 93292516d9a44bb16a19093f38d3fbd562d27133 (patch) | |
tree | 3b3c5059eb27ccfd08d5fb47a68dac497f84ecc0 /apps/files_sharing/appinfo | |
parent | 954596c251cb3132878d8d5eafcc37c47b3f520e (diff) | |
parent | b4de89e6b4c05ddb99010e0dee071c919d338d5e (diff) | |
download | nextcloud-server-93292516d9a44bb16a19093f38d3fbd562d27133.tar.gz nextcloud-server-93292516d9a44bb16a19093f38d3fbd562d27133.zip |
Merge branch 'master' into filesystem
Diffstat (limited to 'apps/files_sharing/appinfo')
-rw-r--r-- | apps/files_sharing/appinfo/update.php | 65 | ||||
-rw-r--r-- | apps/files_sharing/appinfo/version | 2 |
2 files changed, 54 insertions, 13 deletions
diff --git a/apps/files_sharing/appinfo/update.php b/apps/files_sharing/appinfo/update.php index feafa5fb992..5ef7a8bbb9c 100644 --- a/apps/files_sharing/appinfo/update.php +++ b/apps/files_sharing/appinfo/update.php @@ -1,16 +1,57 @@ <?php - -// touch shared directories to trigger one-time re-scan for all users -$datadir = \OCP\Config::getSystemValue('datadirectory'); -$currentVersion=OC_Appconfig::getValue('files_sharing', 'installed_version'); -if (version_compare($currentVersion, '0.2.2', '<')) { - if ($handle = opendir($datadir)) { - while (false !== ($entry = readdir($handle))) { - $sharedFolder = $datadir.'/'.$entry.'/files/Shared'; - if ($entry != "." && $entry != ".." && is_dir($sharedFolder)) { - touch($sharedFolder); +$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(); + while ($row = $result->fetchRow()) { + $itemSource = OC_FileCache::getId($row['source'], ''); + if ($itemSource != -1) { + $file = OC_FileCache::get($row['source'], ''); + if ($file['mimetype'] == 'httpd/unix-directory') { + $itemType = 'folder'; + } else { + $itemType = 'file'; + } + if ($row['permissions'] == 0) { + $permissions = OCP\Share::PERMISSION_READ; + } else { + $permissions = OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_UPDATE; + if ($itemType == 'folder') { + $permissions |= OCP\Share::PERMISSION_CREATE; + } + } + $pos = strrpos($row['uid_shared_with'], '@'); + if ($pos !== false && OC_Group::groupExists(substr($row['uid_shared_with'], $pos + 1))) { + $shareType = OCP\Share::SHARE_TYPE_GROUP; + $shareWith = substr($row['uid_shared_with'], 0, $pos); + if (isset($groupShares[$shareWith][$itemSource])) { + continue; + } else { + $groupShares[$shareWith][$itemSource] = true; + } + } else if ($row['uid_shared_with'] == 'public') { + $shareType = OCP\Share::SHARE_TYPE_LINK; + $shareWith = null; + } else { + $shareType = OCP\Share::SHARE_TYPE_USER; + $shareWith = $row['uid_shared_with']; + } + OC_User::setUserId($row['uid_owner']); + try { + 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/>'; } } - closedir($handle); } -}
\ No newline at end of file + if ($update_error) { + throw new Exception('There were some problems upgrading the sharing of files'); + } + // NOTE: Let's drop the table after more testing +// $query = OCP\DB::prepare('DROP TABLE `*PREFIX*sharing`'); +// $query->execute(); +} diff --git a/apps/files_sharing/appinfo/version b/apps/files_sharing/appinfo/version index a2268e2de44..9fc80f937fa 100644 --- a/apps/files_sharing/appinfo/version +++ b/apps/files_sharing/appinfo/version @@ -1 +1 @@ -0.3.1
\ No newline at end of file +0.3.2
\ No newline at end of file |