diff --git a/DysonNetwork.Drive/Storage/CloudFile.cs b/DysonNetwork.Drive/Storage/CloudFile.cs index 3fcbe6b..0225af4 100644 --- a/DysonNetwork.Drive/Storage/CloudFile.cs +++ b/DysonNetwork.Drive/Storage/CloudFile.cs @@ -9,22 +9,6 @@ using NodaTime.Serialization.Protobuf; namespace DysonNetwork.Drive.Storage; -/// -/// The class that used in jsonb columns which referenced the cloud file. -/// The aim of this class is to store some properties that won't change to a file to reduce the database load. -/// -public class CloudFileReferenceObject : ModelBase, ICloudFile -{ - public string Id { get; set; } = null!; - public string Name { get; set; } = string.Empty; - public Dictionary FileMeta { get; set; } = null!; - public Dictionary? UserMeta { get; set; } = null!; - public string? MimeType { get; set; } - public string? Hash { get; set; } - public long Size { get; set; } - public bool HasCompression { get; set; } = false; -} - public class CloudFile : ModelBase, ICloudFile, IIdentifiedResource { /// The id generated by TuS, basically just UUID remove the dash lines @@ -87,6 +71,7 @@ public class CloudFile : ModelBase, ICloudFile, IIdentifiedResource Name = Name, FileMeta = FileMeta, UserMeta = UserMeta, + SensitiveMarks = SensitiveMarks, MimeType = MimeType, Hash = Hash, Size = Size, @@ -105,7 +90,7 @@ public class CloudFile : ModelBase, ICloudFile, IIdentifiedResource var proto = new Shared.Proto.CloudFile { Id = Id, - Name = Name ?? string.Empty, + Name = Name, MimeType = MimeType ?? string.Empty, Hash = Hash ?? string.Empty, Size = Size, diff --git a/DysonNetwork.Drive/Storage/FileService.cs b/DysonNetwork.Drive/Storage/FileService.cs index d7eb2bd..bce726e 100644 --- a/DysonNetwork.Drive/Storage/FileService.cs +++ b/DysonNetwork.Drive/Storage/FileService.cs @@ -12,6 +12,7 @@ using NetVips; using NodaTime; using tusdotnet.Stores; using System.Linq.Expressions; +using DysonNetwork.Shared.Data; using Microsoft.EntityFrameworkCore.Query; namespace DysonNetwork.Drive.Storage; diff --git a/DysonNetwork.Drive/Storage/FileServiceGrpc.cs b/DysonNetwork.Drive/Storage/FileServiceGrpc.cs index ba4c212..b976021 100644 --- a/DysonNetwork.Drive/Storage/FileServiceGrpc.cs +++ b/DysonNetwork.Drive/Storage/FileServiceGrpc.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Proto; using Google.Protobuf.WellKnownTypes; using Grpc.Core; diff --git a/DysonNetwork.Shared/Data/CloudFileReferenceObject.cs b/DysonNetwork.Shared/Data/CloudFileReferenceObject.cs index ab8df8a..1937356 100644 --- a/DysonNetwork.Shared/Data/CloudFileReferenceObject.cs +++ b/DysonNetwork.Shared/Data/CloudFileReferenceObject.cs @@ -31,6 +31,7 @@ public class CloudFileReferenceObject : ModelBase, ICloudFile public string Name { get; set; } = string.Empty; public Dictionary FileMeta { get; set; } = null!; public Dictionary UserMeta { get; set; } = null!; + public List? SensitiveMarks { get; set; } public string? MimeType { get; set; } public string? Hash { get; set; } public long Size { get; set; } @@ -44,6 +45,7 @@ public class CloudFileReferenceObject : ModelBase, ICloudFile Name = proto.Name, FileMeta = GrpcTypeHelper.ConvertByteStringToObject>(proto.FileMeta) ?? [], UserMeta = GrpcTypeHelper.ConvertByteStringToObject>(proto.UserMeta) ?? [], + SensitiveMarks = GrpcTypeHelper.ConvertByteStringToObject>(proto.SensitiveMarks) ?? [], MimeType = proto.MimeType, Hash = proto.Hash, Size = proto.Size, @@ -73,6 +75,8 @@ public class CloudFileReferenceObject : ModelBase, ICloudFile // Convert user metadata proto.UserMeta = GrpcTypeHelper.ConvertObjectToByteString(UserMeta); + + proto.SensitiveMarks = GrpcTypeHelper.ConvertObjectToByteString(SensitiveMarks); return proto; } diff --git a/DysonNetwork.Shared/Proto/file.proto b/DysonNetwork.Shared/Proto/file.proto index 7097069..0ae27f9 100644 --- a/DysonNetwork.Shared/Proto/file.proto +++ b/DysonNetwork.Shared/Proto/file.proto @@ -24,6 +24,7 @@ message CloudFile { bytes file_meta = 3; // User-defined metadata bytes user_meta = 4; + bytes sensitive_marks = 12; // MIME type of the file string mime_type = 5;