fix(config): improve auto-link UX; fix song update in background job; upsert MusicFile on complex matching
This commit is contained in:
parent
fe3a7abf32
commit
d87d83eaf6
@ -572,12 +572,13 @@ class BackgroundJobService {
|
||||
songUpdates.push({
|
||||
updateOne: {
|
||||
filter: { _id: bestMatch.song._id },
|
||||
update: {
|
||||
$addToSet: {
|
||||
s3File: {
|
||||
musicFileId: musicFile._id,
|
||||
hasS3File: true
|
||||
}
|
||||
update: {
|
||||
$set: {
|
||||
's3File.musicFileId': musicFile._id,
|
||||
's3File.s3Key': musicFile.s3Key,
|
||||
's3File.s3Url': musicFile.s3Url,
|
||||
's3File.streamingUrl': musicFile.s3Key ? `${process.env.S3_ENDPOINT}/${process.env.S3_BUCKET_NAME}/${musicFile.s3Key}` : undefined,
|
||||
's3File.hasS3File': true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,24 +114,25 @@ export const SongMatching: React.FC = () => {
|
||||
}),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
toast({
|
||||
title: 'Auto-linking Complete',
|
||||
description: `Linked ${result.result.linked} files, ${result.result.unmatched} unmatched`,
|
||||
status: 'success',
|
||||
duration: 5000,
|
||||
isClosable: true,
|
||||
});
|
||||
loadData(); // Refresh data
|
||||
} else {
|
||||
throw new Error('Auto-linking failed');
|
||||
if (!response.ok) {
|
||||
const errText = await response.text();
|
||||
throw new Error(errText || 'Auto-linking failed');
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
toast({
|
||||
title: 'Auto-linking Started',
|
||||
description: `Job ${result.jobId} started.`,
|
||||
status: 'info',
|
||||
duration: 4000,
|
||||
isClosable: true,
|
||||
});
|
||||
// Do not call loadData immediately; background job UI will refresh stats as it completes
|
||||
} catch (error) {
|
||||
console.error('Error during auto-linking:', error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: 'Failed to auto-link music files',
|
||||
description: error instanceof Error ? error.message : 'Failed to auto-link music files',
|
||||
status: 'error',
|
||||
duration: 3000,
|
||||
isClosable: true,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user