-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: more changes to signalr models
- Another overhaul of the SingalR models, this time removing an (now) unneeded event model, and also (hopefully) correcting the relative paths to use the correct directory separators for the local os environment and not the environment Shoko Server is running in.
- Loading branch information
Showing
9 changed files
with
189 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,93 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
using Shokofin.SignalR.Interfaces; | ||
|
||
namespace Shokofin.SignalR.Models; | ||
|
||
public class FileMovedEventArgsV1 : IFileRelocationEventArgs | ||
|
||
public class FileMovedEventArgs: FileEventArgs, IFileRelocationEventArgs | ||
{ | ||
/// <summary> | ||
/// Shoko file id. | ||
/// </summary> | ||
[JsonPropertyName("FileID")] | ||
public int FileId { get; set; } | ||
/// <inheritdoc/> | ||
[JsonInclude, JsonPropertyName("PreviousImportFolderID")] | ||
public int PreviousImportFolderId { get; set; } | ||
|
||
/// <summary> | ||
/// The ID of the new import folder the event was detected in. | ||
/// The previous relative path with no leading slash and directory | ||
/// seperators used on the Shoko side. | ||
/// </summary> | ||
/// <value></value> | ||
[JsonPropertyName("NewImportFolderID")] | ||
public int ImportFolderId { get; set; } | ||
[JsonInclude, JsonPropertyName("PreviousRelativePath")] | ||
private string PreviousInternalPath { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// The ID of the old import folder the event was detected in. | ||
/// Cached path for later re-use. | ||
/// </summary> | ||
/// <value></value> | ||
[JsonPropertyName("OldImportFolderID")] | ||
public int PreviousImportFolderId { get; set; } | ||
[JsonIgnore] | ||
private string? PreviousCachedPath { get; set; } | ||
|
||
/// <summary> | ||
/// The relative path of the new file from the import folder base location. | ||
/// </summary> | ||
[JsonPropertyName("NewRelativePath")] | ||
public string RelativePath { get; set; } = string.Empty; | ||
/// <inheritdoc/> | ||
[JsonIgnore] | ||
public string PreviousRelativePath => | ||
PreviousCachedPath ??= System.IO.Path.DirectorySeparatorChar + PreviousInternalPath | ||
.Replace('/', System.IO.Path.DirectorySeparatorChar) | ||
.Replace('\\', System.IO.Path.DirectorySeparatorChar); | ||
|
||
/// <summary> | ||
/// The relative path of the old file from the import folder base location. | ||
/// </summary> | ||
[JsonPropertyName("OldRelativePath")] | ||
public string PreviousRelativePath { get; set; } = string.Empty; | ||
} | ||
public class V0 : IFileRelocationEventArgs | ||
{ | ||
/// <inheritdoc/> | ||
[JsonInclude, JsonPropertyName("FileID")] | ||
public int FileId { get; set; } | ||
|
||
public class FileMovedEventArgs: FileEventArgs, IFileRelocationEventArgs | ||
{ | ||
/// <summary> | ||
/// The ID of the old import folder the event was detected in. | ||
/// </summary> | ||
/// <value></value> | ||
[JsonPropertyName("PreviousImportFolderID")] | ||
public int PreviousImportFolderId { get; set; } | ||
/// <inheritdoc/> | ||
[JsonInclude, JsonPropertyName("NewImportFolderID")] | ||
public int ImportFolderId { get; set; } | ||
|
||
/// <summary> | ||
/// The relative path of the old file from the import folder base location. | ||
/// </summary> | ||
public string PreviousRelativePath { get; set; } = string.Empty; | ||
/// <inheritdoc/> | ||
[JsonInclude, JsonPropertyName("OldImportFolderID")] | ||
public int PreviousImportFolderId { get; set; } | ||
|
||
/// <summary> | ||
/// The relative path with no leading slash and directory seperators used on | ||
/// the Shoko side. | ||
/// </summary> | ||
[JsonInclude, JsonPropertyName("RelativePath")] | ||
private string InternalPath { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// Cached path for later re-use. | ||
/// </summary> | ||
[JsonIgnore] | ||
private string? CachedPath { get; set; } | ||
|
||
/// <inheritdoc/> | ||
[JsonIgnore] | ||
public string RelativePath => | ||
CachedPath ??= System.IO.Path.DirectorySeparatorChar + InternalPath | ||
.Replace('/', System.IO.Path.DirectorySeparatorChar) | ||
.Replace('\\', System.IO.Path.DirectorySeparatorChar); | ||
|
||
|
||
/// <summary> | ||
/// The previous relative path with no leading slash and directory | ||
/// seperators used on the Shoko side. | ||
/// </summary> | ||
[JsonInclude, JsonPropertyName("OldRelativePath")] | ||
private string PreviousInternalPath { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// Cached path for later re-use. | ||
/// </summary> | ||
[JsonIgnore] | ||
private string? PreviousCachedPath { get; set; } | ||
|
||
/// <inheritdoc/> | ||
[JsonIgnore] | ||
public string PreviousRelativePath => | ||
PreviousCachedPath ??= System.IO.Path.DirectorySeparatorChar + PreviousInternalPath | ||
.Replace('/', System.IO.Path.DirectorySeparatorChar) | ||
.Replace('\\', System.IO.Path.DirectorySeparatorChar); | ||
|
||
/// <inheritdoc/> | ||
[JsonIgnore] | ||
public List<IFileEventArgs.FileCrossReference> CrossReferences => new(); | ||
} | ||
} |
Oops, something went wrong.