Allow editing metadata

This commit is contained in:
Kieran
2022-03-15 10:39:36 +00:00
parent 20d32ad6d3
commit 285899b742
11 changed files with 99 additions and 22 deletions

View File

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

View File

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