[未测试] 添加Tag帮助类方法
This commit is contained in:
parent
21b721758c
commit
69296bd413
2 changed files with 47 additions and 4 deletions
|
@ -48,7 +48,7 @@ namespace iFileProxy.Models
|
|||
|
||||
[JsonProperty("tag")]
|
||||
[JsonPropertyName("tag")]
|
||||
public string Tag { get; set; }
|
||||
public string Tag { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("queue_position")]
|
||||
[JsonPropertyName("queue_position")]
|
||||
|
@ -57,10 +57,53 @@ namespace iFileProxy.Models
|
|||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public Process Process { get; set; }
|
||||
|
||||
// Helper to get the tags as a list
|
||||
private List<string> GetTagList()
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(Tag) ? [] : [.. Tag.Split(';')];
|
||||
}
|
||||
|
||||
// Add a new tag
|
||||
public void AddTag(string tag)
|
||||
{
|
||||
var tags = GetTagList();
|
||||
if (!tags.Contains(tag))
|
||||
{
|
||||
tags.Add(tag);
|
||||
Tag = string.Join(";", tags);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove a tag
|
||||
public bool RemoveTag(string tag)
|
||||
{
|
||||
var tags = GetTagList();
|
||||
if (tags.Remove(tag))
|
||||
{
|
||||
Tag = string.Join(";", tags);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find a tag
|
||||
public bool FindTag(string tag)
|
||||
{
|
||||
return GetTagList().Contains(tag);
|
||||
}
|
||||
|
||||
// Get all tags as a list
|
||||
public List<string> GetTags()
|
||||
{
|
||||
return GetTagList();
|
||||
}
|
||||
}
|
||||
|
||||
public class DbConfigName {
|
||||
|
||||
public class DbConfigName
|
||||
{
|
||||
public static string iFileProxy = "iFileProxy_Db";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ namespace iFileProxy.Services
|
|||
taskInfo.Status = TaskState.Cached;
|
||||
taskInfo.Hash = r.Hash;
|
||||
taskInfo.Size = r.Size;
|
||||
taskInfo.Tag = $"REDIRECT:{r.TaskId}";
|
||||
taskInfo.AddTag($"REDIRECT:{r.TaskId}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue