Skip to content

Commit

Permalink
[Last.fm] Fix scrobbling crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Soapwood committed Jul 30, 2024
1 parent 67486ab commit de715cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion VXMusic/Connections/Lastfm/Scrobbling/LastfmScrobbler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ public class LastfmScrobbler
private readonly IServiceProvider _serviceProvider;
private readonly ILogger<LastfmScrobbler> _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<LastfmScrobbler>))
as ILogger<LastfmScrobbler> ?? throw new ApplicationException("A logger must be created in service provider.");

if (!DbFileFileExists)
File.Create(_databasePath);
}

public async Task<ScrobbleResponse> Scrobble(string artist, string album, string trackName)
Expand Down
2 changes: 1 addition & 1 deletion VXMusicDesktop/VXMusicDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageIcon>VXLogo.png</PackageIcon>
<ApplicationIcon>Images\VXLogoIcon.ico</ApplicationIcon>
<RunPostBuildEvent>Always</RunPostBuildEvent>
<Version>0.6.4.18</Version>
<Version>0.6.4.19</Version>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<Title>VXMusicDesktop</Title>
<Authors>VirtualXtensions</Authors>
Expand Down

0 comments on commit de715cc

Please sign in to comment.