Updated file deletion to remove cc_files rows properly when deleting from the Library
This commit is contained in:
parent
365184c2b1
commit
a84e0761ca
2 changed files with 6 additions and 7 deletions
|
@ -384,11 +384,11 @@ SQL;
|
||||||
throw new FileNoPermissionException();
|
throw new FileNoPermissionException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory());
|
$music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory());
|
||||||
assert($music_dir);
|
assert($music_dir);
|
||||||
$type = $music_dir->getType();
|
$type = $music_dir->getType();
|
||||||
|
|
||||||
|
|
||||||
if (file_exists($filepath) && $type == "stor") {
|
if (file_exists($filepath) && $type == "stor") {
|
||||||
try {
|
try {
|
||||||
//Update the user's disk usage
|
//Update the user's disk usage
|
||||||
|
@ -402,11 +402,7 @@ SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logging::info($_SERVER["HTTP_HOST"].": User ".$user->getLogin()." is deleting file: ".$this->_file->getDbTrackTitle()." - file id: ".$this->_file->getDbId());
|
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
|
// need to explicitly update any playlist's and block's length
|
||||||
// that contains the file getting deleted
|
// that contains the file getting deleted
|
||||||
$fileId = $this->_file->getDbId();
|
$fileId = $this->_file->getDbId();
|
||||||
|
@ -423,6 +419,10 @@ SQL;
|
||||||
$bl->setDbLength($bl->computeDbLength(Propel::getConnection(CcBlockPeer::DATABASE_NAME)));
|
$bl->setDbLength($bl->computeDbLength(Propel::getConnection(CcBlockPeer::DATABASE_NAME)));
|
||||||
$bl->save();
|
$bl->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We were setting file_exists to false and leaving it at that
|
||||||
|
// but we should actually delete the file
|
||||||
|
$this->_file->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -277,7 +277,6 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
if ($storedFile->existsOnDisk()) {
|
if ($storedFile->existsOnDisk()) {
|
||||||
$storedFile->delete(); //TODO: This checks your session permissions... Make it work without a session?
|
$storedFile->delete(); //TODO: This checks your session permissions... Make it work without a session?
|
||||||
}
|
}
|
||||||
$file->delete();
|
|
||||||
$this->getResponse()
|
$this->getResponse()
|
||||||
->setHttpResponseCode(204);
|
->setHttpResponseCode(204);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue