Add maintenance management features: implement maintenance endpoints in the API, enhance media upload handling to skip duplicate files, and update frontend routes and translations for maintenance operations.
This commit is contained in:
@@ -33,4 +33,9 @@ public static class MediaErrors
|
||||
"Media.SourceNotFound",
|
||||
"Исходный файл не найден в хранилище."
|
||||
);
|
||||
|
||||
public static readonly Error DuplicateFileName = Error.Conflict(
|
||||
"Media.DuplicateFileName",
|
||||
"Файл с таким именем уже загружен."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using LiteCqrs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Common.Models;
|
||||
using TeleWave.Domain.Media;
|
||||
@@ -15,6 +16,16 @@ public sealed class RegisterMediaAssetCommandHandler(
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
// Дедуп по имени: тот же файл уже в библиотеке (кроме проваленных — их разрешаем перезалить).
|
||||
var duplicate = await dbContext.MediaAssets.AnyAsync(
|
||||
x =>
|
||||
x.OriginalFileName == command.OriginalFileName
|
||||
&& x.Status != MediaAssetStatus.Failed,
|
||||
cancellationToken
|
||||
);
|
||||
if (duplicate)
|
||||
return Result.Failure<Guid>(MediaErrors.DuplicateFileName);
|
||||
|
||||
var extension = Path.GetExtension(command.OriginalFileName).ToLowerInvariant();
|
||||
var asset = MediaAsset.Register(command.OriginalFileName, extension, command.Source);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user