Browse Source

Fix HybridModelFile RelativePath resolving for downloadable resources

pull/333/head
Ionite 1 year ago
parent
commit
3ba0f8b65a
No known key found for this signature in database
  1. 11
      StabilityMatrix.Core/Models/HybridModelFile.cs
  2. 1
      StabilityMatrix.Core/Models/HybridModelType.cs

11
StabilityMatrix.Core/Models/HybridModelFile.cs

@ -32,7 +32,6 @@ public record HybridModelFile
public HybridModelType Type { get; init; }
[MemberNotNullWhen(true, nameof(RemoteName))]
[MemberNotNullWhen(false, nameof(Local))]
[JsonIgnore]
public bool IsRemote => RemoteName != null;
@ -40,7 +39,15 @@ public record HybridModelFile
public bool IsDownloadable => DownloadableResource != null;
[JsonIgnore]
public string RelativePath => IsRemote ? RemoteName : Local.RelativePathFromSharedFolder;
public string RelativePath =>
Type switch
{
HybridModelType.Local => Local!.RelativePathFromSharedFolder,
HybridModelType.Remote => RemoteName!,
HybridModelType.Downloadable => DownloadableResource!.Value.FileName,
HybridModelType.None => throw new InvalidOperationException(),
_ => throw new ArgumentOutOfRangeException()
};
[JsonIgnore]
public string FileName => Path.GetFileName(RelativePath);

1
StabilityMatrix.Core/Models/HybridModelType.cs

@ -2,6 +2,7 @@
public enum HybridModelType
{
None,
Local,
Remote,
Downloadable

Loading…
Cancel
Save