#3553 -- Update modified time even with silent errors.

This commit is contained in:
Buster "Silver Eagle" Neece 2020-12-14 16:39:32 -06:00
parent 8191d9764c
commit 7d927b86ea
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
3 changed files with 32 additions and 14 deletions

View File

@ -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);
}

View File

@ -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;
}
);
}

View File

@ -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;
}
}