diff --git a/src/.idea/.idea.Recyclarr/.idea/inspectionProfiles/Project_Default.xml b/src/.idea/.idea.Recyclarr/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 00000000..7e296f57
--- /dev/null
+++ b/src/.idea/.idea.Recyclarr/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Recyclarr.TrashLib.Tests/Cache/ServiceCacheTest.cs b/src/Recyclarr.TrashLib.Tests/Cache/ServiceCacheTest.cs
index 76cd73ba..b852e8d0 100644
--- a/src/Recyclarr.TrashLib.Tests/Cache/ServiceCacheTest.cs
+++ b/src/Recyclarr.TrashLib.Tests/Cache/ServiceCacheTest.cs
@@ -168,7 +168,7 @@ public class ServiceCacheTest
}
[Test, AutoMockData]
- public void Name_properties_get_truncated_on_load(
+ public void Name_properties_are_set_on_load(
[Frozen(Matching.ImplementedInterfaces)] MockFileSystem fs,
[Frozen] ICacheStoragePath storage,
ServiceCache sut)
@@ -195,7 +195,7 @@ public class ServiceCacheTest
{
TrashIdMappings = new Collection
{
- new("eca37840c13c6ef2dd0262b141a5482f", 4)
+ new("eca37840c13c6ef2dd0262b141a5482f", "4K Remaster", 4)
}
});
}
diff --git a/src/Recyclarr.TrashLib.Tests/CustomFormat/CachePersisterTest.cs b/src/Recyclarr.TrashLib.Tests/CustomFormat/CachePersisterTest.cs
index 74161ee0..72c93b67 100644
--- a/src/Recyclarr.TrashLib.Tests/CustomFormat/CachePersisterTest.cs
+++ b/src/Recyclarr.TrashLib.Tests/CustomFormat/CachePersisterTest.cs
@@ -38,7 +38,7 @@ public class CachePersisterTest
var testCfObj = new CustomFormatCache
{
Version = versionToTest,
- TrashIdMappings = new Collection {new("", 5)}
+ TrashIdMappings = new Collection {new("", "", 5)}
};
ctx.ServiceCache.Load().Returns(testCfObj);
ctx.Persister.Load();
@@ -53,7 +53,7 @@ public class CachePersisterTest
var testCfObj = new CustomFormatCache
{
Version = CustomFormatCache.LatestVersion,
- TrashIdMappings = new Collection {new("", 5)}
+ TrashIdMappings = new Collection {new("", "", 5)}
};
ctx.ServiceCache.Load().Returns(testCfObj);
ctx.Persister.Load();
@@ -108,7 +108,7 @@ public class CachePersisterTest
// Load initial CfCache just to test that it gets replaced
var testCfObj = new CustomFormatCache
{
- TrashIdMappings = new Collection {new("") {CustomFormatId = 5}}
+ TrashIdMappings = new Collection {new("", "") {CustomFormatId = 5}}
};
ctx.ServiceCache.Load().Returns(testCfObj);
ctx.Persister.Load();
@@ -119,7 +119,7 @@ public class CachePersisterTest
var customFormatData = new List
{
- new(NewCf.Data("", "trashid")) {CacheEntry = new TrashIdMapping("trashid", 10)}
+ new(NewCf.Data("", "trashid")) {CacheEntry = new TrashIdMapping("trashid", "", 10)}
};
ctx.Persister.Update(customFormatData);
@@ -130,7 +130,7 @@ public class CachePersisterTest
customFormatData.Should().ContainSingle()
.Which.CacheEntry.Should().BeEquivalentTo(
- new TrashIdMapping("trashid") {CustomFormatId = 10});
+ new TrashIdMapping("trashid", "") {CustomFormatId = 10});
}
[Test]
diff --git a/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/GuideSteps/CustomFormatStepTest.cs b/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/GuideSteps/CustomFormatStepTest.cs
index f29fce0a..015f585d 100644
--- a/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/GuideSteps/CustomFormatStepTest.cs
+++ b/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/GuideSteps/CustomFormatStepTest.cs
@@ -82,13 +82,13 @@ public class CustomFormatStepTest
var testCache = new CustomFormatCache
{
- TrashIdMappings = new Collection {new("id1000")}
+ TrashIdMappings = new Collection {new("id1000", "")}
};
processor.Process(guideData, testConfig, testCache);
processor.DeletedCustomFormatsInCache.Should()
- .BeEquivalentTo(new[] {new TrashIdMapping("id1000")});
+ .BeEquivalentTo(new[] {new TrashIdMapping("id1000", "")});
processor.ProcessedCustomFormats.Should().BeEquivalentTo(new List
{
NewCf.Processed("name1", "id1")
@@ -100,7 +100,7 @@ public class CustomFormatStepTest
{
var cache = new CustomFormatCache
{
- TrashIdMappings = new Collection {new("id1", 9)}
+ TrashIdMappings = new Collection {new("id1", "", 9)}
};
var guideCfs = new List
diff --git a/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/CustomFormatApiPersistenceStepTest.cs b/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/CustomFormatApiPersistenceStepTest.cs
index a6d12e36..18252ad8 100644
--- a/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/CustomFormatApiPersistenceStepTest.cs
+++ b/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/CustomFormatApiPersistenceStepTest.cs
@@ -14,7 +14,7 @@ public class CustomFormatApiPersistenceStepTest
{
private static ProcessedCustomFormatData QuickMakeCf(string cfName, string trashId, int cfId)
{
- return NewCf.Processed(cfName, trashId, new TrashIdMapping(trashId) {CustomFormatId = cfId});
+ return NewCf.Processed(cfName, trashId, new TrashIdMapping(trashId, cfName) {CustomFormatId = cfId});
}
[Test]
@@ -24,7 +24,7 @@ public class CustomFormatApiPersistenceStepTest
transactions.NewCustomFormats.Add(QuickMakeCf("cfname1", "trashid1", 1));
transactions.UpdatedCustomFormats.Add(QuickMakeCf("cfname2", "trashid2", 2));
transactions.UnchangedCustomFormats.Add(QuickMakeCf("cfname3", "trashid3", 3));
- transactions.DeletedCustomFormatIds.Add(new TrashIdMapping("trashid4") {CustomFormatId = 4});
+ transactions.DeletedCustomFormatIds.Add(new TrashIdMapping("trashid4", "cfname4") {CustomFormatId = 4});
var api = Substitute.For();
diff --git a/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/JsonTransactionStepTest.cs b/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/JsonTransactionStepTest.cs
index 0d2fb1f9..ad4d1a2e 100644
--- a/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/JsonTransactionStepTest.cs
+++ b/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/JsonTransactionStepTest.cs
@@ -120,8 +120,8 @@ public class JsonTransactionStepTest
var guideCfs = new List
{
NewCf.Processed("created", "id1", guideCfData[0]),
- NewCf.Processed("updated_different_name", "id2", guideCfData[1], new TrashIdMapping("id2", 2)),
- NewCf.Processed("no_change", "id3", guideCfData[2], new TrashIdMapping("id3", 3))
+ NewCf.Processed("updated_different_name", "id2", guideCfData[1], new TrashIdMapping("id2", "", 2)),
+ NewCf.Processed("no_change", "id3", guideCfData[2], new TrashIdMapping("id3", "", 3))
};
var processor = new JsonTransactionStep();
@@ -227,12 +227,12 @@ public class JsonTransactionStepTest
}");
var deletedCfsInCache = new List
{
- new("") {CustomFormatId = 2}
+ new("", "") {CustomFormatId = 2}
};
var guideCfs = new List
{
- NewCf.Processed("updated", "", guideCfData, new TrashIdMapping("") {CustomFormatId = 1})
+ NewCf.Processed("updated", "", guideCfData, new TrashIdMapping("", "") {CustomFormatId = 1})
};
var radarrCfs = JsonConvert.DeserializeObject>(radarrCfData);
@@ -253,7 +253,7 @@ public class JsonTransactionStepTest
}]
}";
var expectedTransactions = new CustomFormatTransactionData();
- expectedTransactions.DeletedCustomFormatIds.Add(new TrashIdMapping("", 2));
+ expectedTransactions.DeletedCustomFormatIds.Add(new TrashIdMapping("", "", 2));
expectedTransactions.UpdatedCustomFormats.Add(guideCfs[0]);
processor.Transactions.Should().BeEquivalentTo(expectedTransactions);
@@ -290,8 +290,8 @@ public class JsonTransactionStepTest
}]";
var deletedCfsInCache = new List
{
- new("testtrashid", 2),
- new("", 3)
+ new("testtrashid", "", 2),
+ new("", "", 3)
};
var radarrCfs = JsonConvert.DeserializeObject>(radarrCfData);
@@ -300,7 +300,7 @@ public class JsonTransactionStepTest
processor.RecordDeletions(deletedCfsInCache, radarrCfs!);
var expectedTransactions = new CustomFormatTransactionData();
- expectedTransactions.DeletedCustomFormatIds.Add(new TrashIdMapping("testtrashid", 2));
+ expectedTransactions.DeletedCustomFormatIds.Add(new TrashIdMapping("testtrashid", "", 2));
processor.Transactions.Should().BeEquivalentTo(expectedTransactions);
}
}
diff --git a/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/QualityProfileApiPersistenceStepTest.cs b/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/QualityProfileApiPersistenceStepTest.cs
index c3911a07..eb102f0a 100644
--- a/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/QualityProfileApiPersistenceStepTest.cs
+++ b/src/Recyclarr.TrashLib.Tests/CustomFormat/Processors/PersistenceSteps/QualityProfileApiPersistenceStepTest.cs
@@ -48,7 +48,7 @@ public class QualityProfileApiPersistenceStepTest
{
{
"profile1", CfTestUtils.NewMapping(new FormatMappingEntry(
- NewCf.Processed("", "", new TrashIdMapping("") {CustomFormatId = 4}), 100))
+ NewCf.Processed("", "", new TrashIdMapping("", "") {CustomFormatId = 4}), 100))
}
};
@@ -109,7 +109,7 @@ public class QualityProfileApiPersistenceStepTest
{
{
"profile1", CfTestUtils.NewMappingWithReset(
- new FormatMappingEntry(NewCf.Processed("", "", new TrashIdMapping("", 2)), 100))
+ new FormatMappingEntry(NewCf.Processed("", "", new TrashIdMapping("", "", 2)), 100))
}
};
@@ -183,11 +183,11 @@ public class QualityProfileApiPersistenceStepTest
{
"profile1", CfTestUtils.NewMapping(
// First match by ID
- new FormatMappingEntry(NewCf.Processed("", "", new TrashIdMapping("", 4)), 100),
+ new FormatMappingEntry(NewCf.Processed("", "", new TrashIdMapping("", "", 4)), 100),
// Should NOT match because we do not use names to assign scores
- new FormatMappingEntry(NewCf.Processed("", "", new TrashIdMapping("")), 101),
+ new FormatMappingEntry(NewCf.Processed("", "", new TrashIdMapping("", "")), 101),
// Second match by ID
- new FormatMappingEntry(NewCf.Processed("", "", new TrashIdMapping("", 1)), 102))
+ new FormatMappingEntry(NewCf.Processed("", "", new TrashIdMapping("", "", 1)), 102))
}
};
diff --git a/src/Recyclarr.TrashLib/Services/CustomFormat/Models/Cache/CustomFormatCache.cs b/src/Recyclarr.TrashLib/Services/CustomFormat/Models/Cache/CustomFormatCache.cs
index 222bd5a5..3dd2bb95 100644
--- a/src/Recyclarr.TrashLib/Services/CustomFormat/Models/Cache/CustomFormatCache.cs
+++ b/src/Recyclarr.TrashLib/Services/CustomFormat/Models/Cache/CustomFormatCache.cs
@@ -14,12 +14,14 @@ public class CustomFormatCache
public class TrashIdMapping
{
- public TrashIdMapping(string trashId, int customFormatId = default)
+ public TrashIdMapping(string trashId, string customFormatName, int customFormatId = default)
{
TrashId = trashId;
+ CustomFormatName = customFormatName;
CustomFormatId = customFormatId;
}
public string TrashId { get; }
+ public string CustomFormatName { get; }
public int CustomFormatId { get; set; }
}
diff --git a/src/Recyclarr.TrashLib/Services/CustomFormat/Models/ProcessedCustomFormatData.cs b/src/Recyclarr.TrashLib/Services/CustomFormat/Models/ProcessedCustomFormatData.cs
index 12a46174..4a13ad8e 100644
--- a/src/Recyclarr.TrashLib/Services/CustomFormat/Models/ProcessedCustomFormatData.cs
+++ b/src/Recyclarr.TrashLib/Services/CustomFormat/Models/ProcessedCustomFormatData.cs
@@ -22,7 +22,8 @@ public class ProcessedCustomFormatData
public void SetCache(int customFormatId)
{
- CacheEntry ??= new TrashIdMapping(TrashId);
+ // Do not pass the customFormatId to constructor since an instance may already exist.
+ CacheEntry ??= new TrashIdMapping(TrashId, Name);
CacheEntry.CustomFormatId = customFormatId;
}
diff --git a/src/Recyclarr.TrashLib/Services/CustomFormat/Processors/PersistenceSteps/JsonTransactionStep.cs b/src/Recyclarr.TrashLib/Services/CustomFormat/Processors/PersistenceSteps/JsonTransactionStep.cs
index b4fdfc36..f15bd0a6 100644
--- a/src/Recyclarr.TrashLib/Services/CustomFormat/Processors/PersistenceSteps/JsonTransactionStep.cs
+++ b/src/Recyclarr.TrashLib/Services/CustomFormat/Processors/PersistenceSteps/JsonTransactionStep.cs
@@ -64,8 +64,7 @@ internal class JsonTransactionStep : IJsonTransactionStep
// The 'Where' excludes cached CFs that were deleted manually by the user in Radarr
// FindRadarrCf() specifies 'null' for name because we should never delete unless an ID is found
- foreach (var del in deletedCfsInCache.Where(
- del => FindServiceCf(cfs, del.CustomFormatId) != null))
+ foreach (var del in deletedCfsInCache.Where(del => FindServiceCf(cfs, del.CustomFormatId) != null))
{
Transactions.DeletedCustomFormatIds.Add(del);
}