diff --git a/apps/files_archive/lib/storage.php b/apps/files_archive/lib/storage.php index 8676166361..2f10d6a3e4 100644 --- a/apps/files_archive/lib/storage.php +++ b/apps/files_archive/lib/storage.php @@ -49,6 +49,7 @@ class OC_Filestorage_Archive extends OC_Filestorage_Common{ OC_FakeDirStream::$dirs[$id]=$content; return opendir('fakedir://'.$id); } + public function readdir($path){} public function stat($path){ $ctime=filectime($this->path); $path=$this->stripPath($path); diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php index 1a6942ad16..9174334383 100644 --- a/apps/files_sharing/sharedstorage.php +++ b/apps/files_sharing/sharedstorage.php @@ -139,6 +139,8 @@ class OC_Filestorage_Shared extends OC_Filestorage { } } + public function readdir( $path ) {} + public function is_dir($path) { if ($path == "" || $path == "/") { return true; diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php index 44ce7c635a..6feb0cbb9c 100644 --- a/apps/files_versions/versions.php +++ b/apps/files_versions/versions.php @@ -303,66 +303,88 @@ class Storage { */ public static function expireAll() { - function deleteAll($directory, $empty = false) { + function deleteAll( $directory, $empty = false ) { - if(substr($directory,-1) == "/") { - $directory = substr($directory,0,-1); + // strip leading slash + if( substr( $directory, 0, 1 ) == "/" ) { + + $directory = substr( $directory, 1 ); + + } + + // strip trailing slash + if( substr( $directory, -1) == "/" ) { + + $directory = substr( $directory, 0, -1 ); + } - if(!file_exists($directory) || !is_dir($directory)) { + $view = new \OC_FilesystemView(''); + + if ( !$view->file_exists( $directory ) || !$view->is_dir( $directory ) ) { return false; - } elseif(!is_readable($directory)) { + } elseif( !$view->is_readable( $directory ) ) { return false; } else { - $directoryHandle = opendir($directory); - - while ($contents = readdir($directoryHandle)) { + $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 - if( $contents != '.' && $contents != '..') { + $directoryHandle = opendir( $foldername ); + + while ( $contents = $view->readdir( $directoryHandle ) ) { + + if ( $contents != '.' && $contents != '..') { $path = $directory . "/" . $contents; - if( is_dir($path) ) { + if ( $view->is_dir( $path ) ) { - deleteAll($path); + deleteAll( $path ); } else { - - unlink($path); + + $view->unlink( \OCP\USER::getUser() .'/' . $path ); // TODO: make unlink use same system path as is_dir } } } - closedir( $directoryHandle ); + //$view->closedir( $directoryHandle ); // TODO: implement closedir in OC_FSV - if( $empty == false ) { + if ( $empty == false ) { - if(!rmdir($directory)) { + if ( !$view->rmdir( $directory ) ) { return false; } - } + } return true; } } - - /* - // FIXME: make this path dynamic - $dir = '/home/samtuke/owncloud/git/oc5/data/admin/versions'; + + $dir = \OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); + + deleteAll( $dir, true ); - ( deleteAll( $dir, 1 ) ? return true : return false ); - */ +// if ( deleteAll( $dir, 1 ) ) { +// +// echo "