🐛 Fix bugs

This commit is contained in:
2025-08-05 02:10:41 +08:00
parent a9a5082e1a
commit 9e9d0dc563
5 changed files with 9 additions and 17 deletions

View File

@@ -9,22 +9,6 @@ using NodaTime.Serialization.Protobuf;
namespace DysonNetwork.Drive.Storage; namespace DysonNetwork.Drive.Storage;
/// <summary>
/// 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.
/// </summary>
public class CloudFileReferenceObject : ModelBase, ICloudFile
{
public string Id { get; set; } = null!;
public string Name { get; set; } = string.Empty;
public Dictionary<string, object?> FileMeta { get; set; } = null!;
public Dictionary<string, object>? 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 public class CloudFile : ModelBase, ICloudFile, IIdentifiedResource
{ {
/// The id generated by TuS, basically just UUID remove the dash lines /// The id generated by TuS, basically just UUID remove the dash lines
@@ -87,6 +71,7 @@ public class CloudFile : ModelBase, ICloudFile, IIdentifiedResource
Name = Name, Name = Name,
FileMeta = FileMeta, FileMeta = FileMeta,
UserMeta = UserMeta, UserMeta = UserMeta,
SensitiveMarks = SensitiveMarks,
MimeType = MimeType, MimeType = MimeType,
Hash = Hash, Hash = Hash,
Size = Size, Size = Size,
@@ -105,7 +90,7 @@ public class CloudFile : ModelBase, ICloudFile, IIdentifiedResource
var proto = new Shared.Proto.CloudFile var proto = new Shared.Proto.CloudFile
{ {
Id = Id, Id = Id,
Name = Name ?? string.Empty, Name = Name,
MimeType = MimeType ?? string.Empty, MimeType = MimeType ?? string.Empty,
Hash = Hash ?? string.Empty, Hash = Hash ?? string.Empty,
Size = Size, Size = Size,

View File

@@ -12,6 +12,7 @@ using NetVips;
using NodaTime; using NodaTime;
using tusdotnet.Stores; using tusdotnet.Stores;
using System.Linq.Expressions; using System.Linq.Expressions;
using DysonNetwork.Shared.Data;
using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query;
namespace DysonNetwork.Drive.Storage; namespace DysonNetwork.Drive.Storage;

View File

@@ -1,3 +1,4 @@
using DysonNetwork.Shared.Data;
using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Proto;
using Google.Protobuf.WellKnownTypes; using Google.Protobuf.WellKnownTypes;
using Grpc.Core; using Grpc.Core;

View File

@@ -31,6 +31,7 @@ public class CloudFileReferenceObject : ModelBase, ICloudFile
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public Dictionary<string, object?> FileMeta { get; set; } = null!; public Dictionary<string, object?> FileMeta { get; set; } = null!;
public Dictionary<string, object?> UserMeta { get; set; } = null!; public Dictionary<string, object?> UserMeta { get; set; } = null!;
public List<ContentSensitiveMark>? SensitiveMarks { get; set; }
public string? MimeType { get; set; } public string? MimeType { get; set; }
public string? Hash { get; set; } public string? Hash { get; set; }
public long Size { get; set; } public long Size { get; set; }
@@ -44,6 +45,7 @@ public class CloudFileReferenceObject : ModelBase, ICloudFile
Name = proto.Name, Name = proto.Name,
FileMeta = GrpcTypeHelper.ConvertByteStringToObject<Dictionary<string, object?>>(proto.FileMeta) ?? [], FileMeta = GrpcTypeHelper.ConvertByteStringToObject<Dictionary<string, object?>>(proto.FileMeta) ?? [],
UserMeta = GrpcTypeHelper.ConvertByteStringToObject<Dictionary<string, object?>>(proto.UserMeta) ?? [], UserMeta = GrpcTypeHelper.ConvertByteStringToObject<Dictionary<string, object?>>(proto.UserMeta) ?? [],
SensitiveMarks = GrpcTypeHelper.ConvertByteStringToObject<List<ContentSensitiveMark>>(proto.SensitiveMarks) ?? [],
MimeType = proto.MimeType, MimeType = proto.MimeType,
Hash = proto.Hash, Hash = proto.Hash,
Size = proto.Size, Size = proto.Size,
@@ -73,6 +75,8 @@ public class CloudFileReferenceObject : ModelBase, ICloudFile
// Convert user metadata // Convert user metadata
proto.UserMeta = GrpcTypeHelper.ConvertObjectToByteString(UserMeta); proto.UserMeta = GrpcTypeHelper.ConvertObjectToByteString(UserMeta);
proto.SensitiveMarks = GrpcTypeHelper.ConvertObjectToByteString(SensitiveMarks);
return proto; return proto;
} }

View File

@@ -24,6 +24,7 @@ message CloudFile {
bytes file_meta = 3; bytes file_meta = 3;
// User-defined metadata // User-defined metadata
bytes user_meta = 4; bytes user_meta = 4;
bytes sensitive_marks = 12;
// MIME type of the file // MIME type of the file
string mime_type = 5; string mime_type = 5;