35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
#nullable disable
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace LightlessSync.FileCache;
|
|
|
|
public class FileCacheEntity
|
|
{
|
|
[JsonConstructor]
|
|
public FileCacheEntity(
|
|
string hash,
|
|
string prefixedFilePath,
|
|
string lastModifiedDateTicks,
|
|
long? size = null,
|
|
long? compressedSize = null)
|
|
{
|
|
Size = size;
|
|
CompressedSize = compressedSize;
|
|
Hash = hash;
|
|
PrefixedFilePath = prefixedFilePath;
|
|
LastModifiedDateTicks = lastModifiedDateTicks;
|
|
}
|
|
|
|
public long? CompressedSize { get; set; }
|
|
public string CsvEntry => $"{Hash}{FileCacheManager.CsvSplit}{PrefixedFilePath}{FileCacheManager.CsvSplit}{LastModifiedDateTicks}|{Size ?? -1}|{CompressedSize ?? -1}";
|
|
public string Hash { get; set; }
|
|
public bool IsCacheEntry => PrefixedFilePath.StartsWith(FileCacheManager.CachePrefix, StringComparison.OrdinalIgnoreCase);
|
|
public string LastModifiedDateTicks { get; set; }
|
|
public string PrefixedFilePath { get; init; }
|
|
public string ResolvedFilepath { get; private set; } = string.Empty;
|
|
public long? Size { get; set; }
|
|
|
|
public void SetResolvedFilePath(string filePath)
|
|
=> ResolvedFilepath = filePath.ToLowerInvariant().Replace("\\\\", "\\", StringComparison.Ordinal);
|
|
} |