summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-10-26 23:05:02 +0200
committerRobin Appelman <icewind@owncloud.com>2012-10-26 23:05:02 +0200
commit6db81afab9d68ccd50c1e164622252e47ae76c2f (patch)
treed4ae92ab7ee21805e52a29e4099daeb4649ca79e
parent4b616764e825022e9394a4cb26af2012276285b4 (diff)
downloadnextcloud-server-6db81afab9d68ccd50c1e164622252e47ae76c2f.tar.gz
nextcloud-server-6db81afab9d68ccd50c1e164622252e47ae76c2f.zip
move some stuff to the new api
-rw-r--r--apps/files/ajax/list.php2
-rw-r--r--apps/files/ajax/newfile.php12
-rw-r--r--apps/files/ajax/newfolder.php3
-rw-r--r--apps/files/ajax/rawlist.php2
-rw-r--r--apps/files/ajax/upload.php2
-rw-r--r--apps/files/index.php2
-rw-r--r--apps/files/settings.php2
-rw-r--r--apps/files_encryption/lib/cryptstream.php2
-rw-r--r--apps/files_encryption/lib/proxy.php10
-rw-r--r--apps/files_sharing/appinfo/update.php3
-rw-r--r--lib/connector/sabre/directory.php6
-rw-r--r--lib/connector/sabre/node.php4
-rw-r--r--lib/fileproxy/quota.php12
-rw-r--r--lib/files.php2
-rw-r--r--lib/files/filesystem.php13
-rw-r--r--lib/files/view.php1
-rw-r--r--lib/ocs.php4
-rw-r--r--lib/public/share.php15
-rw-r--r--lib/search/provider/file.php2
-rw-r--r--settings/personal.php4
20 files changed, 58 insertions, 45 deletions
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php
index 568fe754c02..92091f42135 100644
--- a/apps/files/ajax/list.php
+++ b/apps/files/ajax/list.php
@@ -32,7 +32,7 @@ if($doBreadcrumb) {
// make filelist
$files = array();
-foreach( OC_Files::getdirectorycontent( $dir ) as $i ) {
+foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $i ) {
$i["date"] = OCP\Util::formatDate($i["mtime"] );
$files[] = $i;
}
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index 5f3f3d88f27..38714f34a63 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -65,9 +65,9 @@ if($source) {
$target=$dir.'/'.$filename;
$result=\OC\Files\Filesystem::file_put_contents($target, $sourceStream);
if($result) {
- $meta = OC_FileCache::get($target);
+ $meta = \OC\Files\Filesystem::getFileInfo($target);
$mime=$meta['mimetype'];
- $id = OC_FileCache::getId($target);
+ $id = $meta['fileid'];
$eventSource->send('success', array('mime'=>$mime, 'size'=>\OC\Files\Filesystem::filesize($target), 'id' => $id));
} else {
$eventSource->send('error', "Error while downloading ".$source. ' to '.$target);
@@ -77,14 +77,14 @@ if($source) {
} else {
if($content) {
if(\OC\Files\Filesystem::file_put_contents($dir.'/'.$filename, $content)) {
- $meta = OC_FileCache::get($dir.'/'.$filename);
- $id = OC_FileCache::getId($dir.'/'.$filename);
+ $meta = \OC\Files\Filesystem::getFileInfo($dir.'/'.$filename);
+ $id = $meta['fileid'];
OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id)));
exit();
}
}elseif(\OC\Files\Filesystem::touch($dir . '/' . $filename)) {
- $meta = OC_FileCache::get($dir.'/'.$filename);
- $id = OC_FileCache::getId($dir.'/'.$filename);
+ $meta = \OC\Files\Filesystem::getFileInfo($dir.'/'.$filename);
+ $id = $meta['fileid'];
OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id)));
exit();
}
diff --git a/apps/files/ajax/newfolder.php b/apps/files/ajax/newfolder.php
index c36c2084551..e26e1238bc6 100644
--- a/apps/files/ajax/newfolder.php
+++ b/apps/files/ajax/newfolder.php
@@ -25,7 +25,8 @@ if(\OC\Files\Filesystem::mkdir($dir . '/' . stripslashes($foldername))) {
} else {
$path = '/'.$foldername;
}
- $id = OC_FileCache::getId($path);
+ $meta = \OC\Files\Filesystem::getFileInfo($path);
+ $id = $meta['fileid'];
OCP\JSON::success(array("data" => array('id'=>$id)));
exit();
}
diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php
index e0aa0bdac52..1cd2944483c 100644
--- a/apps/files/ajax/rawlist.php
+++ b/apps/files/ajax/rawlist.php
@@ -15,7 +15,7 @@ $mimetype = isset($_GET['mimetype']) ? $_GET['mimetype'] : '';
// make filelist
$files = array();
-foreach( OC_Files::getdirectorycontent( $dir, $mimetype ) as $i ) {
+foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, $mimetype ) as $i ) {
$i["date"] = OCP\Util::formatDate($i["mtime"] );
$i['mimetype_icon'] = $i['type'] == 'dir' ? \mimetype_icon('dir'): \mimetype_icon($i['mimetype']);
$files[] = $i;
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index b6b8c7f7b46..2a784d61691 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -49,7 +49,7 @@ if(strpos($dir, '..') === false) {
for($i=0;$i<$fileCount;$i++) {
$target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
if(is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
- $meta = \OC_Files::getFileInfo($target);
+ $meta = \OC\Files\Filesystem::getFileInfo($target);
$id = $meta['fileid'];
$result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'], 'id'=>$id, 'name'=>basename($target));
}
diff --git a/apps/files/index.php b/apps/files/index.php
index 192cd2696f2..4676ebc6021 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -44,7 +44,7 @@ if(!\OC\Files\Filesystem::is_dir($dir.'/')) {
}
$files = array();
-foreach( OC_Files::getdirectorycontent( $dir ) as $i ) {
+foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $i ) {
$i['date'] = OCP\Util::formatDate($i['mtime'] );
if($i['type']=='file') {
$fileinfo=pathinfo($i['name']);
diff --git a/apps/files/settings.php b/apps/files/settings.php
index 52ec9fd0fe3..30463210f71 100644
--- a/apps/files/settings.php
+++ b/apps/files/settings.php
@@ -36,7 +36,7 @@ OCP\Util::addscript( "files", "files" );
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
$files = array();
-foreach( OC_Files::getdirectorycontent( $dir ) as $i ) {
+foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $i ) {
$i["date"] = date( $CONFIG_DATEFORMAT, $i["mtime"] );
$files[] = $i;
}
diff --git a/apps/files_encryption/lib/cryptstream.php b/apps/files_encryption/lib/cryptstream.php
index e98013e1f42..c4298382646 100644
--- a/apps/files_encryption/lib/cryptstream.php
+++ b/apps/files_encryption/lib/cryptstream.php
@@ -167,7 +167,7 @@ class OC_CryptStream{
public function stream_close() {
$this->flush();
if($this->meta['mode']!='r' and $this->meta['mode']!='rb') {
- OC_FileCache::put($this->path, array('encrypted'=>true,'size'=>$this->size),'');
+ \OC\Files\Filesystem::putFileInfo($this->path, array('encrypted'=>true,'size'=>$this->size),'');
}
return fclose($this->source);
}
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 7b7bafe73eb..49fb30ac291 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -59,7 +59,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
* @return bool
*/
private static function isEncrypted($path) {
- $metadata=OC_FileCache_Cached::get($path,'');
+ $metadata=\OC\Files\Filesystem::getFileInfo($path,'');
return isset($metadata['encrypted']) and (bool)$metadata['encrypted'];
}
@@ -68,14 +68,14 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
if (!is_resource($data)) {//stream put contents should have been converter to fopen
$size=strlen($data);
$data=OC_Crypt::blockEncrypt($data);
- OC_FileCache::put($path, array('encrypted'=>true,'size'=>$size),'');
+ \OC\Files\Filesystem::putFileInfo($path, array('encrypted'=>true,'size'=>$size),'');
}
}
}
public function postFile_get_contents($path,$data) {
if(self::isEncrypted($path)) {
- $cached=OC_FileCache_Cached::get($path,'');
+ $cached=\OC\Files\Filesystem::getFileInfo($path,'');
$data=OC_Crypt::blockDecrypt($data,'',$cached['size']);
}
return $data;
@@ -113,7 +113,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
public function postStat($path,$data) {
if(self::isEncrypted($path)) {
- $cached=OC_FileCache_Cached::get($path,'');
+ $cached=\OC\Files\Filesystem::getFileInfo($path,'');
$data['size']=$cached['size'];
}
return $data;
@@ -121,7 +121,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
public function postFileSize($path,$size) {
if(self::isEncrypted($path)) {
- $cached=OC_FileCache_Cached::get($path,'');
+ $cached=\OC\Files\Filesystem::getFileInfo($path,'');
return $cached['size'];
}else{
return $size;
diff --git a/apps/files_sharing/appinfo/update.php b/apps/files_sharing/appinfo/update.php
index e75c538b150..51048bd178c 100644
--- a/apps/files_sharing/appinfo/update.php
+++ b/apps/files_sharing/appinfo/update.php
@@ -10,6 +10,7 @@ if (version_compare($installedVersion, '0.3', '<')) {
OC_Group::useBackend(new OC_Group_Database());
OC_App::loadApps(array('authentication'));
while ($row = $result->fetchRow()) {
+ $meta = \OC\Files\Filesystem::getId($path, '');
$itemSource = OC_FileCache::getId($row['source'], '');
if ($itemSource != -1) {
$file = OC_FileCache::get($row['source'], '');
@@ -70,4 +71,4 @@ if (version_compare($installedVersion, '0.3.3', '<')) {
foreach ($users as $user) {
OC_FileCache::delete('Shared', '/'.$user.'/files/');
}
-} \ No newline at end of file
+}
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index 3df85b2bbbe..d4f58527d21 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -93,7 +93,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
$path = $this->path . '/' . $name;
if (is_null($info)) {
- $info = OC_Files::getFileInfo($path);
+ $info = \OC\Files\Filesystem::getFileInfo($path);
}
if (!$info) {
@@ -117,7 +117,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
*/
public function getChildren() {
- $folder_content = OC_Files::getDirectoryContent($this->path);
+ $folder_content = \OC\Files\Filesystem::getDirectoryContent($this->path);
$paths = array();
foreach($folder_content as $info) {
$paths[] = $this->path.'/'.$info['name'];
@@ -178,7 +178,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
* @return array
*/
public function getQuotaInfo() {
- $rootInfo=OC_FileCache_Cached::get('');
+ $rootInfo=\OC\Files\Filesystem::getFileInfo('');
return array(
$rootInfo['size'],
\OC\Files\Filesystem::free_space()
diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php
index e7e83507ea2..2095c956e5f 100644
--- a/lib/connector/sabre/node.php
+++ b/lib/connector/sabre/node.php
@@ -95,11 +95,11 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
}
/**
- * Make sure the fileinfo cache is filled. Uses OC_FileCache or a direct stat
+ * Make sure the fileinfo cache is filled. Uses the file cache or a direct stat
*/
protected function getFileinfoCache() {
if (!isset($this->fileinfo_cache)) {
- if ($fileinfo_cache = \OC\Files\Filesystem::get($this->path)) {
+ if ($fileinfo_cache = \OC\Files\Filesystem::getFileInfo($this->path)) {
} else {
$fileinfo_cache = \OC\Files\Filesystem::stat($this->path);
}
diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php
index d120f309998..cd9a2f4a192 100644
--- a/lib/fileproxy/quota.php
+++ b/lib/fileproxy/quota.php
@@ -57,7 +57,7 @@ class OC_FileProxy_Quota extends OC_FileProxy{
* @return int
*/
private function getFreeSpace($path) {
- $storage=OC_Filesystem::getStorage($path);
+ list($storage,)=\OC\Files\Filesystem::resolvePath($path);
$owner=$storage->getOwner($path);
$totalSpace=$this->getQuota($owner);
@@ -65,13 +65,9 @@ class OC_FileProxy_Quota extends OC_FileProxy{
return 0;
}
- $rootInfo=OC_FileCache::get('', "/".$owner."/files");
- // TODO Remove after merge of share_api
- if (OC_FileCache::inCache('/Shared', "/".$owner."/files")) {
- $sharedInfo=OC_FileCache::get('/Shared', "/".$owner."/files");
- } else {
- $sharedInfo = null;
- }
+ $view = new \OC\Files\View("/".$owner."/files");
+
+ $rootInfo=$view->getFileInfo('/');
$usedSpace=isset($rootInfo['size'])?$rootInfo['size']:0;
$usedSpace=isset($sharedInfo['size'])?$usedSpace-$sharedInfo['size']:$usedSpace;
return $totalSpace-$usedSpace;
diff --git a/lib/files.php b/lib/files.php
index 422e7f4ffe7..6a063f216d5 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -146,7 +146,7 @@ class OC_Files {
$dirname = basename($dir);
$zip->addEmptyDir($internalDir . $dirname);
$internalDir .= $dirname .= '/';
- $files = OC_Files::getdirectorycontent($dir);
+ $files = \OC\Files\Filesystem::getDirectoryContent($dir);
foreach ($files as $file) {
$filename = $file['name'];
$file = $dir . '/' . $filename;
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index 4031c0c5b80..b3c92f38558 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -628,6 +628,19 @@ class Filesystem {
}
/**
+ * change file metadata
+ *
+ * @param string $path
+ * @param array $data
+ * @return int
+ *
+ * returns the fileid of the updated file
+ */
+ public static function putFileInfo($path, $data) {
+ return self::$defaultInstance->putFileInfo($path, $data);
+ }
+
+ /**
* get the content of a directory
*
* @param string $directory path under datadirectory
diff --git a/lib/files/view.php b/lib/files/view.php
index ee95cce0c1d..e9b583f8ae6 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -451,7 +451,6 @@ class View {
array(Filesystem::signal_param_path => $path2)
);
} else { // no real copy, file comes from somewhere else, e.g. version rollback -> just update the file cache and the webdav properties without all the other post_write actions
-// OC_FileCache_Update::update($path2, $this->fakeRoot);
Filesystem::removeETagHook(array("path" => $path2), $this->fakeRoot);
}
return $result;
diff --git a/lib/ocs.php b/lib/ocs.php
index 645380ddba8..c6bcd2c06e1 100644
--- a/lib/ocs.php
+++ b/lib/ocs.php
@@ -590,8 +590,8 @@ class OC_OCS {
// calculate the disc space
$user_dir = '/'.$user.'/files';
\OC\Files\Filesystem::init($user_dir);
- $rootInfo=OC_FileCache::get('');
- $sharedInfo=OC_FileCache::get('/Shared');
+ $rootInfo=\OC\Files\Filesystem::getFileInfo('');
+ $sharedInfo=\OC\Files\Filesystem::getFileInfo('/Shared');
$used=$rootInfo['size']-$sharedInfo['size'];
$free=\OC\Files\Filesystem::free_space();
$total=$free+$used;
diff --git a/lib/public/share.php b/lib/public/share.php
index 7a9a087d1bd..dd6c841c99d 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -285,10 +285,10 @@ class Share {
// If the item is a folder, scan through the folder looking for equivalent item types
if ($itemType == 'folder') {
$parentFolder = self::put('folder', $itemSource, $shareType, $shareWith, $uidOwner, $permissions, true);
- if ($parentFolder && $files = \OC_Files::getDirectoryContent($itemSource)) {
+ if ($parentFolder && $files = \OC\Files\Filesystem::getDirectoryContent($itemSource)) {
for ($i = 0; $i < count($files); $i++) {
$name = substr($files[$i]['name'], strpos($files[$i]['name'], $itemSource) - strlen($itemSource));
- if ($files[$i]['mimetype'] == 'httpd/unix-directory' && $children = \OC_Files::getDirectoryContent($name, '/')) {
+ if ($files[$i]['mimetype'] == 'httpd/unix-directory' && $children = \OC\Files\Filesystem::getDirectoryContent($name, '/')) {
// Continue scanning into child folders
array_push($files, $children);
} else {
@@ -768,9 +768,10 @@ class Share {
if ($row['item_type'] == 'file' || $row['item_type'] == 'folder') {
$childItem['file_source'] = $child['source'];
} else {
- $childItem['file_source'] = \OC_FileCache::getId($child['file_path']);
+ $meta = \OC\Files\Filesystem::getFileInfo($child['file_path']);
+ $childItem['file_source'] = $meta['fileid'];
}
- $childItem['file_target'] = \OC_Filesystem::normalizePath($child['file_path']);
+ $childItem['file_target'] = \OC\Files\Filesystem::normalizePath($child['file_path']);
}
if (isset($item)) {
if ($childItem[$column] == $item) {
@@ -881,7 +882,8 @@ class Share {
if ($itemType == 'file' || $itemType == 'folder') {
$fileSource = $itemSource;
} else {
- $fileSource = \OC_FileCache::getId($filePath);
+ $meta = \OC\Files\Filesystem::getFileInfo($filePath);
+ $fileSource = $meta['fileid'];
}
if ($fileSource == -1) {
$message = 'Sharing '.$itemSource.' failed, because the file could not be found in the file cache';
@@ -1063,7 +1065,8 @@ class Share {
}
if ($item['uid_owner'] == $uidOwner) {
if ($itemType == 'file' || $itemType == 'folder') {
- if ($item['file_source'] == \OC_FileCache::getId($itemSource)) {
+ $meta = \OC\Files\Filesystem::getFileInfo($itemSource);
+ if ($item['file_source'] == $meta['fileid']) {
return $target;
}
} else if ($item['item_source'] == $itemSource) {
diff --git a/lib/search/provider/file.php b/lib/search/provider/file.php
index 0d4b332b792..456e12b5ec2 100644
--- a/lib/search/provider/file.php
+++ b/lib/search/provider/file.php
@@ -2,7 +2,7 @@
class OC_Search_Provider_File extends OC_Search_Provider{
function search($query) {
- $files=OC_FileCache::search($query, true);
+ $files=\OC\Files\Filesystem::search($query, true);
$results=array();
$l=OC_L10N::get('lib');
foreach($files as $fileData) {
diff --git a/settings/personal.php b/settings/personal.php
index c73a3dd3701..5a267ec2844 100644
--- a/settings/personal.php
+++ b/settings/personal.php
@@ -16,8 +16,8 @@ OC_Util::addStyle( '3rdparty', 'chosen' );
OC_App::setActiveNavigationEntry( 'personal' );
// calculate the disc space
-$rootInfo=OC_FileCache::get('');
-$sharedInfo=OC_FileCache::get('/Shared');
+$rootInfo=\OC\Files\Filesystem::getFileInfo('');
+$sharedInfo=\OC\Files\Filesystem::getFileInfo('/Shared');
$used=$rootInfo['size'];
if($used<0) $used=0;
$free=\OC\Files\Filesystem::free_space();