Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1200 from njam/issue-1200
Browse files Browse the repository at this point in the history
Delete video streamchannel thumbnails recursively
  • Loading branch information
njam committed May 8, 2014
2 parents 34c5993 + 1608f61 commit 5522e6d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 3 additions & 1 deletion library/CM/File/Filesystem/Adapter/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
7 changes: 1 addition & 6 deletions library/CM/Model/StreamChannelArchive/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
21 changes: 14 additions & 7 deletions tests/library/CM/File/Filesystem/Adapter/LocalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 5522e6d

Please sign in to comment.