diff --git a/Jellyfin.Plugin.SmartPlaylist/Lisp/Expression.cs b/Jellyfin.Plugin.SmartPlaylist/Lisp/Expression.cs index b27f686..a5c3979 100644 --- a/Jellyfin.Plugin.SmartPlaylist/Lisp/Expression.cs +++ b/Jellyfin.Plugin.SmartPlaylist/Lisp/Expression.cs @@ -126,6 +126,12 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp { public static Boolean operator <=(Integer a, Integer b) { return (a._value <= b._value) ? Boolean.TRUE : Boolean.FALSE; } + public override int GetHashCode() { + return base.GetHashCode(); + } + public override bool Equals(object? other) { + return base.Equals(other); + } public static Boolean operator ==(Integer a, Integer b) { return (a._value == b._value) ? Boolean.TRUE : Boolean.FALSE; } diff --git a/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs b/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs index 7ad36c0..7d68941 100644 --- a/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs +++ b/Jellyfin.Plugin.SmartPlaylist/Lisp/Interpreter.cs @@ -7,7 +7,7 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp { using FunctionLater = Func, Expression>; public interface IEnvironment { - public V Get(K k); + public V? Get(K k); public void Set(K k, V v); public IEnvironment? Find(K k); public IEnvironment Parent(bool recursive); @@ -377,7 +377,11 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp { if (_environment.Find(s.Name()) is not IEnvironment env) { throw new ApplicationException($"Could not find '{s.Name()}'"); } - return env.Get(s.Name()); + var r_ = env.Get(s.Name()); + if (r_ is null) { + throw new ApplicationException($"Could not find '{s.Name()}'"); + } + return r_; case Boolean b: return b; case Integer i: diff --git a/Jellyfin.Plugin.SmartPlaylist/Store.cs b/Jellyfin.Plugin.SmartPlaylist/Store.cs index 2fdf84d..a388125 100644 --- a/Jellyfin.Plugin.SmartPlaylist/Store.cs +++ b/Jellyfin.Plugin.SmartPlaylist/Store.cs @@ -14,7 +14,7 @@ namespace Jellyfin.Plugin.SmartPlaylist { _fileSystem = fileSystem; } private async Task LoadPlaylistAsync(string filename) { - var r = File.ReadAllText(filename); + var r = await File.ReadAllTextAsync(filename); if (r.Equals("")) { r = "{}"; } @@ -46,7 +46,7 @@ namespace Jellyfin.Plugin.SmartPlaylist { public async Task SaveSmartPlaylistAsync(SmartPlaylistDto smartPlaylist) { string filename = _fileSystem.GetSmartPlaylistFilePath(smartPlaylist.Id); var text = new SerializerBuilder().Build().Serialize(smartPlaylist); - File.WriteAllText(filename, text); + await File.WriteAllTextAsync(filename, text); } private void DeleteSmartPlaylistById(SmartPlaylistId smartPlaylistId) { try { diff --git a/Tests/Tests.cs b/Tests/Tests.cs index 3413bf3..4052b24 100644 --- a/Tests/Tests.cs +++ b/Tests/Tests.cs @@ -1,5 +1,3 @@ -using Xunit; -using Lisp_Environment = Jellyfin.Plugin.SmartPlaylist.Lisp.Environment; using Lisp_Boolean = Jellyfin.Plugin.SmartPlaylist.Lisp.Boolean; using Lisp_Object = Jellyfin.Plugin.SmartPlaylist.Lisp.Object; using Jellyfin.Plugin.SmartPlaylist.Lisp;