#3553 -- Update modified time even with silent errors.
This commit is contained in:
parent
8191d9764c
commit
7d927b86ea
|
@ -245,13 +245,10 @@ class FilesController extends AbstractStationApiCrudController
|
|||
}
|
||||
|
||||
if ($record instanceof Entity\StationMedia) {
|
||||
$this->mediaRepo->writeToFile($record);
|
||||
$this->em->persist($record);
|
||||
$this->em->flush();
|
||||
|
||||
if ($this->mediaRepo->writeToFile($record)) {
|
||||
$record->updateSongId();
|
||||
}
|
||||
|
||||
if (null !== $custom_fields) {
|
||||
$this->customFieldsRepo->setCustomFields($record, $custom_fields);
|
||||
}
|
||||
|
|
|
@ -345,14 +345,24 @@ class StationMediaRepository extends Repository
|
|||
}
|
||||
|
||||
// Write tags to the Media file.
|
||||
$media->setMtime(time() + 5);
|
||||
$media->updateSongId();
|
||||
|
||||
return $fs->withLocalFile(
|
||||
$media->getPath(),
|
||||
function ($path) use ($media, $metadata) {
|
||||
if ($this->metadataManager->writeMetadata($metadata, $path)) {
|
||||
$media->setMtime(time() + 5);
|
||||
function ($path) use ($metadata) {
|
||||
try {
|
||||
$this->metadataManager->writeMetadata($metadata, $path);
|
||||
return true;
|
||||
} catch (CannotProcessMediaException $e) {
|
||||
$this->logger->error(
|
||||
$e->getMessage(),
|
||||
[
|
||||
'exception' => $e,
|
||||
]
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -24,11 +24,13 @@ class GetId3MetadataManager implements MetadataManagerInterface
|
|||
$info = $id3->analyze($path);
|
||||
|
||||
if (!empty($info['error'])) {
|
||||
throw new CannotProcessMediaException(sprintf(
|
||||
'Cannot process media file at path "%s": %s',
|
||||
pathinfo($path, PATHINFO_FILENAME),
|
||||
json_encode($info['error'], JSON_THROW_ON_ERROR)
|
||||
));
|
||||
throw new CannotProcessMediaException(
|
||||
sprintf(
|
||||
'Cannot process media file at path "%s": %s',
|
||||
pathinfo($path, PATHINFO_FILENAME),
|
||||
json_encode($info['error'], JSON_THROW_ON_ERROR)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$metadata = new Metadata();
|
||||
|
@ -121,6 +123,15 @@ class GetId3MetadataManager implements MetadataManagerInterface
|
|||
|
||||
$tagwriter->tag_data = $tagData;
|
||||
|
||||
return $tagwriter->WriteTags();
|
||||
$writeTagsResult = $tagwriter->WriteTags();
|
||||
|
||||
if (false === $writeTagsResult) {
|
||||
throw CannotProcessMediaException::forPath(
|
||||
$path,
|
||||
implode(', ', $tagwriter->errors)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue