mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Fixed: Recycle Metadata files on episode removal.
This commit is contained in:
parent
52588509ed
commit
3573e631c8
@ -49,8 +49,6 @@ public ExtraFileService(IExtraFileRepository<TExtraFile> repository,
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public virtual bool PermanentlyDelete => false;
|
||||
|
||||
public List<TExtraFile> GetFilesBySeries(int seriesId)
|
||||
{
|
||||
return _repository.GetFilesBySeries(seriesId);
|
||||
@ -122,17 +120,9 @@ public void Handle(EpisodeFileDeletedEvent message)
|
||||
|
||||
if (_diskProvider.FileExists(path))
|
||||
{
|
||||
if (PermanentlyDelete)
|
||||
{
|
||||
_diskProvider.DeleteFile(path);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Send extra files to the recycling bin so they can be recovered if necessary
|
||||
var subfolder = _diskProvider.GetParentFolder(series.Path).GetRelativePath(_diskProvider.GetParentFolder(path));
|
||||
_recycleBinProvider.DeleteFile(path, subfolder);
|
||||
}
|
||||
// Send to the recycling bin so they can be recovered if necessary
|
||||
var subfolder = _diskProvider.GetParentFolder(series.Path).GetRelativePath(_diskProvider.GetParentFolder(path));
|
||||
_recycleBinProvider.DeleteFile(path, subfolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,5 @@ public MetadataFileService(IExtraFileRepository<MetadataFile> repository, ISerie
|
||||
: base(repository, seriesService, diskProvider, recycleBinProvider, logger)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool PermanentlyDelete => true;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public class MetadataService : ExtraFileManager<MetadataFile>
|
||||
{
|
||||
private readonly IMetadataFactory _metadataFactory;
|
||||
private readonly ICleanMetadataService _cleanMetadataService;
|
||||
private readonly IRecycleBinProvider _recycleBinProvider;
|
||||
private readonly IDiskTransferService _diskTransferService;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IHttpClient _httpClient;
|
||||
@ -29,6 +30,7 @@ public class MetadataService : ExtraFileManager<MetadataFile>
|
||||
public MetadataService(IConfigService configService,
|
||||
IDiskProvider diskProvider,
|
||||
IDiskTransferService diskTransferService,
|
||||
IRecycleBinProvider recycleBinProvider,
|
||||
IMetadataFactory metadataFactory,
|
||||
ICleanMetadataService cleanMetadataService,
|
||||
IHttpClient httpClient,
|
||||
@ -39,6 +41,7 @@ public MetadataService(IConfigService configService,
|
||||
{
|
||||
_metadataFactory = metadataFactory;
|
||||
_cleanMetadataService = cleanMetadataService;
|
||||
_recycleBinProvider = recycleBinProvider;
|
||||
_diskTransferService = diskTransferService;
|
||||
_diskProvider = diskProvider;
|
||||
_httpClient = httpClient;
|
||||
@ -443,11 +446,11 @@ private MetadataFile GetMetadataFile(Series series, List<MetadataFile> existingM
|
||||
|
||||
_logger.Debug("Removing duplicate Metadata file: {0}", path);
|
||||
|
||||
_diskProvider.DeleteFile(path);
|
||||
var subfolder = _diskProvider.GetParentFolder(series.Path).GetRelativePath(_diskProvider.GetParentFolder(path));
|
||||
_recycleBinProvider.DeleteFile(path, subfolder);
|
||||
_metadataFileService.Delete(file.Id);
|
||||
}
|
||||
|
||||
|
||||
return matchingMetadataFiles.First();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user