mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-13 03:27:45 +02:00
fix(media): copy and delete temp file when saving instead of moving it for FS FileManager
+ throw exception instead silently failing file save closes #338
This commit is contained in:
parent
0775add678
commit
9346e787bd
10 changed files with 59 additions and 57 deletions
|
|
@ -117,12 +117,13 @@ class MediaModel extends Model
|
|||
public function saveMedia(object $media): int | false
|
||||
{
|
||||
// save file first
|
||||
if (! $media->saveFile()) {
|
||||
return false;
|
||||
}
|
||||
$media->saveFile();
|
||||
|
||||
// insert record in database
|
||||
if (! $mediaId = $this->insert($media, true)) {
|
||||
/** @var int|false $mediaId */
|
||||
$mediaId = $this->insert($media, true);
|
||||
|
||||
if (! $mediaId) {
|
||||
$this->db->transRollback();
|
||||
|
||||
return false;
|
||||
|
|
@ -137,10 +138,10 @@ class MediaModel extends Model
|
|||
public function updateMedia(object $media): bool
|
||||
{
|
||||
// save file first
|
||||
if (! $media->saveFile()) {
|
||||
return false;
|
||||
}
|
||||
// FIXME: what if file is not set?
|
||||
$media->saveFile();
|
||||
|
||||
// update record in database
|
||||
return $this->update($media->id, $media);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue