@ -23,8 +23,9 @@ public class CacheCleanerService : IHostedService
@@ -23,8 +23,9 @@ public class CacheCleanerService : IHostedService
{
using IServiceScope scope = _ serviceScopeFactory . CreateScope ( ) ;
await using TvContext dbContext = scope . ServiceProvider . GetRequiredService < TvContext > ( ) ;
ILocalFileSystem localFileSystem = scope . ServiceProvider . GetRequiredService < ILocalFileSystem > ( ) ;
if ( Directory . Exists ( FileSystemLayout . LegacyImageCacheFolder ) )
if ( localFileSystem . Folder Exists( FileSystemLayout . LegacyImageCacheFolder ) )
{
_l ogger . LogInformation ( "Migrating channel logos from legacy image cache folder" ) ;
@ -34,13 +35,12 @@ public class CacheCleanerService : IHostedService
@@ -34,13 +35,12 @@ public class CacheCleanerService : IHostedService
. Map ( a = > a . Path )
. ToListAsync ( cancellationToken ) ;
ILocalFileSystem localFileSystem = scope . ServiceProvider . GetRequiredService < ILocalFileSystem > ( ) ;
foreach ( string logo in logos )
{
string legacyPath = Path . Combine ( FileSystemLayout . LegacyImageCacheFolder , logo ) ;
if ( File . Exists ( legacyPath ) )
if ( local FileSystem . File Exists( legacyPath ) )
{
string subfolder = logo . Substring ( 0 , 2 ) ;
string subfolder = logo [ . . 2 ] ;
string newPath = Path . Combine ( FileSystemLayout . LogoCacheFolder , subfolder , logo ) ;
await localFileSystem . CopyFile ( legacyPath , newPath ) ;
}
@ -49,6 +49,12 @@ public class CacheCleanerService : IHostedService
@@ -49,6 +49,12 @@ public class CacheCleanerService : IHostedService
_l ogger . LogInformation ( "Deleting legacy image cache folder" ) ;
Directory . Delete ( FileSystemLayout . LegacyImageCacheFolder , true ) ;
}
if ( localFileSystem . FolderExists ( FileSystemLayout . TranscodeFolder ) )
{
_l ogger . LogInformation ( "Emptying transcode cache folder" ) ;
localFileSystem . EmptyFolder ( FileSystemLayout . TranscodeFolder ) ;
}
}
public Task StopAsync ( CancellationToken cancellationToken ) = > Task . CompletedTask ;