From de715cc163d38076b8a8346733a0a667921af991 Mon Sep 17 00:00:00 2001 From: Soapwood Date: Tue, 30 Jul 2024 11:09:56 +0100 Subject: [PATCH] [Last.fm] Fix scrobbling crash --- VXMusic/Connections/Lastfm/Scrobbling/LastfmScrobbler.cs | 9 ++++++++- VXMusicDesktop/VXMusicDesktop.csproj | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/VXMusic/Connections/Lastfm/Scrobbling/LastfmScrobbler.cs b/VXMusic/Connections/Lastfm/Scrobbling/LastfmScrobbler.cs index 6b397af..f5e16df 100644 --- a/VXMusic/Connections/Lastfm/Scrobbling/LastfmScrobbler.cs +++ b/VXMusic/Connections/Lastfm/Scrobbling/LastfmScrobbler.cs @@ -11,13 +11,20 @@ public class LastfmScrobbler private readonly IServiceProvider _serviceProvider; private readonly ILogger _logger; - private static readonly string _databasePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "vxscrobbles.db"); + public static bool DbFileFileExists => File.Exists(_databasePath); + + private static readonly string _databasePath = + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "VirtualXtensions", + "VXMusic", "Cache", "vxscrobbles.db"); public LastfmScrobbler(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; _logger = _serviceProvider.GetService(typeof(ILogger)) as ILogger ?? throw new ApplicationException("A logger must be created in service provider."); + + if (!DbFileFileExists) + File.Create(_databasePath); } public async Task Scrobble(string artist, string album, string trackName) diff --git a/VXMusicDesktop/VXMusicDesktop.csproj b/VXMusicDesktop/VXMusicDesktop.csproj index 9335206..65ad22f 100644 --- a/VXMusicDesktop/VXMusicDesktop.csproj +++ b/VXMusicDesktop/VXMusicDesktop.csproj @@ -9,7 +9,7 @@ VXLogo.png Images\VXLogoIcon.ico Always - 0.6.4.18 + 0.6.4.19 en VXMusicDesktop VirtualXtensions