From abacd12e9c7bd4170c2ed61ff01a2b986913ccd9 Mon Sep 17 00:00:00 2001 From: Reto Kaiser Date: Thu, 8 May 2014 10:09:04 +0200 Subject: [PATCH 1/2] listByPrefix should only list directory-contents on local FS --- library/CM/File/Filesystem/Adapter/Local.php | 4 +++- .../CM/File/Filesystem/Adapter/LocalTest.php | 21 ++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/library/CM/File/Filesystem/Adapter/Local.php b/library/CM/File/Filesystem/Adapter/Local.php index b1df840ee..be74c8e85 100644 --- a/library/CM/File/Filesystem/Adapter/Local.php +++ b/library/CM/File/Filesystem/Adapter/Local.php @@ -70,7 +70,9 @@ public function delete($path) { public function listByPrefix($pathPrefix) { $fileList = array(); $dirList = array(); - $this->_listByPrefixRecursive($pathPrefix, $fileList, $dirList); + if ($this->isDirectory($pathPrefix)) { + $this->_listByPrefixRecursive($pathPrefix, $fileList, $dirList); + } return array('files' => $fileList, 'dirs' => $dirList); } diff --git a/tests/library/CM/File/Filesystem/Adapter/LocalTest.php b/tests/library/CM/File/Filesystem/Adapter/LocalTest.php index 8281e944e..bd6661547 100644 --- a/tests/library/CM/File/Filesystem/Adapter/LocalTest.php +++ b/tests/library/CM/File/Filesystem/Adapter/LocalTest.php @@ -204,8 +204,8 @@ public function testListByPrefix() { $filesystem = new CM_File_Filesystem($this->_adapter); $pathList = array( - 'foo/foobar/bar', 'foo/bar2', + 'foo/foobar/bar', 'foo/bar', ); foreach ($pathList as $path) { @@ -238,12 +238,19 @@ public function testListByPrefix() { ), $this->_adapter->listByPrefix('/foo')); } - /** - * @expectedException CM_Exception - * @expectedExceptionMessage Cannot scan directory - */ - public function testListByPrefixInvalid() { - $this->_adapter->listByPrefix('nonexistent'); + public function testListByPrefixNonexistent() { + $this->assertSame(array( + 'files' => array(), + 'dirs' => array(), + ), $this->_adapter->listByPrefix('nonexistent')); + } + + public function testListByPrefixFile() { + $this->_adapter->write('/foo', 'hello'); + $this->assertSame(array( + 'files' => array(), + 'dirs' => array(), + ), $this->_adapter->listByPrefix('/foo')); } public function testEquals() { From 1608f610bac494f4082a5dec736622671428f1f7 Mon Sep 17 00:00:00 2001 From: Reto Kaiser Date: Thu, 8 May 2014 10:36:47 +0200 Subject: [PATCH 2/2] Delete streamchannelArchvive thumbnails recursively --- library/CM/Model/StreamChannelArchive/Video.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/library/CM/Model/StreamChannelArchive/Video.php b/library/CM/Model/StreamChannelArchive/Video.php index e8ecb9ab4..98b3f3458 100644 --- a/library/CM/Model/StreamChannelArchive/Video.php +++ b/library/CM/Model/StreamChannelArchive/Video.php @@ -102,13 +102,8 @@ protected function _loadData() { protected function _onDeleteBefore() { $this->getVideo()->delete(); - /** @var CM_File_UserContent $thumbnail */ - foreach ($this->getThumbnails() as $thumbnail) { - $thumbnail->delete(); - } - $thumbnailDir = new CM_File_UserContent('streamChannels', $this->getId() . '-' . $this->getHash() . '-thumbs/', $this->getId()); - $thumbnailDir->delete(); + $thumbnailDir->delete(true); } protected function _onDelete() {