summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorSam Tuke <samtuke@owncloud.com>2012-06-21 18:07:21 +0100
committerSam Tuke <samtuke@owncloud.com>2012-06-21 18:15:22 +0100
commita9a913c27304c395c3f6af3487781d02790b8009 (patch)
treec0da4444f8cce48974e5391b3ea37bdf55a6139e /apps
parent49033ff8e0dd89d964264f269930b0587b8479c4 (diff)
downloadnextcloud-server-a9a913c27304c395c3f6af3487781d02790b8009.tar.gz
nextcloud-server-a9a913c27304c395c3f6af3487781d02790b8009.zip
Implemented deleteAll() method in OC_FilesystemView (interface) and OC_Filestorage_Common (logic)
Made OC_Filestorage_Local and OC_Filestorage_Shared extend OC_Filestorage_Common Set searchInDir() to protected instead of private in OC_Filestorage_Local and OC_Filestorage_Shared Added class documentation to OC_Filestorage_Common Cleaned up OCA_Versions::expireAll()
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/sharedstorage.php4
-rw-r--r--apps/files_versions/versions.php86
2 files changed, 7 insertions, 83 deletions
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index 62c86ee18e4..fed1b834fa3 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -25,7 +25,7 @@ require_once( 'lib_share.php' );
/**
* Convert target path to source path and pass the function call to the correct storage provider
*/
-class OC_Filestorage_Shared extends OC_Filestorage {
+class OC_Filestorage_Shared extends OC_Filestorage_Common {
private $datadir;
private $sourcePaths = array();
@@ -492,7 +492,7 @@ class OC_Filestorage_Shared extends OC_Filestorage {
return $this->searchInDir($query);
}
- private function searchInDir($query, $path = "") {
+ protected function searchInDir($query, $path = "") {
$files = array();
if ($dh = $this->opendir($path)) {
while (($filename = readdir($dh)) !== false) {
diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php
index 7522538caf2..9c0829ff1de 100644
--- a/apps/files_versions/versions.php
+++ b/apps/files_versions/versions.php
@@ -261,10 +261,8 @@ class Storage {
}
-
-
/**
- * expire old versions of a file.
+ * @brief Erase a file's versions which exceed the set quota
*/
public static function expire($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
@@ -298,90 +296,16 @@ class Storage {
}
/**
- * @brief erase all old versions of all user files
- * @return
+ * @brief Erase all old versions of all user files
+ * @return true/false
*/
public static function expireAll() {
-
- function deleteAll( $directory, $empty = false ) {
- // strip leading slash
- if( substr( $directory, 0, 1 ) == "/" ) {
-
- $directory = substr( $directory, 1 );
-
- }
-
- // strip trailing slash
- if( substr( $directory, -1) == "/" ) {
-
- $directory = substr( $directory, 0, -1 );
-
- }
-
- $view = new \OC_FilesystemView('');
-
- if ( !$view->file_exists( $directory ) || !$view->is_dir( $directory ) ) {
-
- return false;
-
- } elseif( !$view->is_readable( $directory ) ) {
-
- return false;
-
- } else {
-
- $foldername = \OCP\Config::getSystemValue('datadirectory') .'/' . \OCP\USER::getUser() .'/' . $directory; // have to set an absolute path for use with PHP's opendir as OC version doesn't work
-
- $directoryHandle = $view->opendir( \OCP\USER::getUser() . '/' . $directory );
-
- while ( $contents = readdir( $directoryHandle ) ) {
-
- if ( $contents != '.' && $contents != '..') {
-
- $path = $directory . "/" . $contents;
-
- if ( $view->is_dir( $path ) ) {
-
- deleteAll( $path );
-
- } else {
-
- $view->unlink( \OCP\USER::getUser() .'/' . $path ); // TODO: make unlink use same system path as is_dir
-
- }
- }
-
- }
-
- //$view->closedir( $directoryHandle ); // TODO: implement closedir in OC_FSV
-
- if ( $empty == false ) {
-
- if ( !$view->rmdir( $directory ) ) {
-
- return false;
-
- }
-
- }
-
- return true;
- }
-
- }
+ $view = new \OC_FilesystemView('');
$dir = \OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER);
- if ( deleteAll( $dir, true ) ) {
-
- return true;
-
- } else {
-
- return false;
-
- }
+ return $view->deleteAll( $dir, true );
}