Added playlist repository logic.

This commit is contained in:
2025-02-18 20:49:04 -05:00
parent 8cf4bb2804
commit 2bafd474a0
7 changed files with 182 additions and 6 deletions

View File

@@ -0,0 +1,22 @@
using Harmonia.Core.Models;
namespace Harmonia.Core.Data;
public class PlaylistRepository : JsonFileRepository<Playlist>
{
protected override string DirectoryName => string.Empty;
protected override string GetNewFileName()
{
for (int i = 0; i < 1000; i++)
{
string shortFileName = $"Playlist{i.ToString().PadLeft(3, '0')}.{Extension}";
string filePath = Path.Combine(DirectoryName, shortFileName);
if (File.Exists(filePath) == false)
return shortFileName;
}
throw new Exception("Unable to determine new fileName");
}
}