Updated file deletion to remove cc_files rows properly when deleting from the Library

This commit is contained in:
Duncan Sommerville 2014-10-08 18:01:06 -04:00
parent 365184c2b1
commit a84e0761ca
2 changed files with 6 additions and 7 deletions

View file

@ -384,11 +384,11 @@ SQL;
throw new FileNoPermissionException();
}
$music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory());
assert($music_dir);
$type = $music_dir->getType();
if (file_exists($filepath) && $type == "stor") {
try {
//Update the user's disk usage
@ -402,10 +402,6 @@ SQL;
}
Logging::info($_SERVER["HTTP_HOST"].": User ".$user->getLogin()." is deleting file: ".$this->_file->getDbTrackTitle()." - file id: ".$this->_file->getDbId());
// set hidden flag to true
//$this->_file->setDbHidden(true);
$this->_file->setDbFileExists(false);
$this->_file->save();
// need to explicitly update any playlist's and block's length
// that contains the file getting deleted
@ -423,6 +419,10 @@ SQL;
$bl->setDbLength($bl->computeDbLength(Propel::getConnection(CcBlockPeer::DATABASE_NAME)));
$bl->save();
}
// We were setting file_exists to false and leaving it at that
// but we should actually delete the file
$this->_file->delete();
}
/**

View file

@ -277,7 +277,6 @@ class Rest_MediaController extends Zend_Rest_Controller
if ($storedFile->existsOnDisk()) {
$storedFile->delete(); //TODO: This checks your session permissions... Make it work without a session?
}
$file->delete();
$this->getResponse()
->setHttpResponseCode(204);
} else {