-
Notifications
You must be signed in to change notification settings - Fork 157
/
WindowsDirectory.cs
42 lines (37 loc) · 1.44 KB
/
WindowsDirectory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibationFileManager
{
public static class WindowsDirectory
{
public static void SetCoverAsFolderIcon(string pictureId, string directory)
{
try
{
//Currently only works for Windows and macOS
if (!Configuration.Instance.UseCoverAsFolderIcon || Configuration.IsLinux)
return;
// get path of cover art in Images dir. Download first if not exists
var coverArtPath = PictureStorage.GetPicturePathSynchronously(new(pictureId, PictureSize._300x300));
InteropFactory.Create().SetFolderIcon(image: coverArtPath, directory: directory);
}
catch (Exception ex)
{
// Failure to 'set cover as folder icon' should not be considered a failure to download the book
Serilog.Log.Logger.Error(ex, "Error setting cover art as folder icon. {@DebugInfo}", new { directory });
try
{
InteropFactory.Create().DeleteFolderIcon(directory);
}
catch
{
Serilog.Log.Logger.Error(ex, "Error rolling back: setting cover art as folder icon. {@DebugInfo}", new { directory });
}
}
}
}
}