fix(legacy): do not delete audio file when removing artwork (#2395)
* fix: do not delete audio file when removing artwork * replace glob with explicit filenames --------- Co-authored-by: jo <ljonas@riseup.net>
This commit is contained in:
parent
b0721edde5
commit
a2aca7ddb4
|
@ -305,15 +305,31 @@ class FileDataHelper
|
|||
|
||||
$fp = Config::getStoragePath();
|
||||
|
||||
$dbAudioPath = $md['MDATA_KEY_ARTWORK'];
|
||||
$fullpath = $fp . $dbAudioPath;
|
||||
$artworkBasePath = $fp . $md['MDATA_KEY_ARTWORK'];
|
||||
$audioPath = $fp . $md['MDATA_KEY_FILEPATH'];
|
||||
|
||||
if (file_exists($fullpath)) {
|
||||
foreach (glob("{$fullpath}*", GLOB_NOSORT) as $filename) {
|
||||
$artworkPaths = [
|
||||
$artworkBasePath,
|
||||
$artworkBasePath . '-32.jpg',
|
||||
$artworkBasePath . '-64.jpg',
|
||||
$artworkBasePath . '-128.jpg',
|
||||
$artworkBasePath . '-256.jpg',
|
||||
$artworkBasePath . '-512.jpg',
|
||||
$artworkBasePath . '-32',
|
||||
$artworkBasePath . '-64',
|
||||
$artworkBasePath . '-128',
|
||||
$artworkBasePath . '-256',
|
||||
];
|
||||
|
||||
foreach ($artworkPaths as $filename) {
|
||||
// This should never happen. Make sure we don't delete the audio file.
|
||||
if ($filename == $audioPath) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file_exists($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Could not locate file ' . $filepath);
|
||||
}
|
||||
|
||||
return '';
|
||||
|
|
Loading…
Reference in New Issue