mirror of
https://git.v0l.io/Kieran/void.cat.git
synced 2025-11-15 08:17:36 +01:00
Allow editing metadata
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using VoidCat.Model;
|
||||
using VoidCat.Model.Exceptions;
|
||||
using VoidCat.Services.Abstractions;
|
||||
|
||||
namespace VoidCat.Services.Files;
|
||||
@@ -28,6 +27,18 @@ public class LocalDiskFileMetadataStore : IFileMetadataStore
|
||||
return GetMeta<TMeta>(id);
|
||||
}
|
||||
|
||||
public async ValueTask Update<TMeta>(Guid id, TMeta meta) where TMeta : VoidFileMeta
|
||||
{
|
||||
var oldMeta = await GetMeta<SecretVoidFileMeta>(id);
|
||||
if (oldMeta == default) return;
|
||||
|
||||
oldMeta.Description = meta.Description ?? oldMeta.Description;
|
||||
oldMeta.Name = meta.Name ?? oldMeta.Name;
|
||||
oldMeta.MimeType = meta.MimeType ?? oldMeta.MimeType;
|
||||
|
||||
await Set(id, oldMeta);
|
||||
}
|
||||
|
||||
public ValueTask<VoidFileMeta?> Get(Guid id)
|
||||
{
|
||||
return GetMeta<VoidFileMeta>(id);
|
||||
|
||||
@@ -25,6 +25,18 @@ public class S3FileMetadataStore : IFileMetadataStore
|
||||
return GetMeta<TMeta>(id);
|
||||
}
|
||||
|
||||
public async ValueTask Update<TMeta>(Guid id, TMeta meta) where TMeta : VoidFileMeta
|
||||
{
|
||||
var oldMeta = await GetMeta<SecretVoidFileMeta>(id);
|
||||
if (oldMeta == default) return;
|
||||
|
||||
oldMeta.Description = meta.Description ?? oldMeta.Description;
|
||||
oldMeta.Name = meta.Name ?? oldMeta.Name;
|
||||
oldMeta.MimeType = meta.MimeType ?? oldMeta.MimeType;
|
||||
|
||||
await Set(id, oldMeta);
|
||||
}
|
||||
|
||||
public ValueTask<VoidFileMeta?> Get(Guid id)
|
||||
{
|
||||
return GetMeta<VoidFileMeta>(id);
|
||||
|
||||
Reference in New Issue
Block a user