mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-25 07:12:40 +00:00
Fixed: Update path before importing to ensure it hasn't changed
Fixes #1847
This commit is contained in:
parent
e6489eaca3
commit
b3352564fa
1 changed files with 37 additions and 15 deletions
|
@ -26,19 +26,19 @@ public class CompletedDownloadService : ICompletedDownloadService
|
||||||
private readonly IHistoryService _historyService;
|
private readonly IHistoryService _historyService;
|
||||||
private readonly IDownloadedTracksImportService _downloadedTracksImportService;
|
private readonly IDownloadedTracksImportService _downloadedTracksImportService;
|
||||||
private readonly IArtistService _artistService;
|
private readonly IArtistService _artistService;
|
||||||
private readonly IProvideImportItemService _importItemService;
|
private readonly IProvideImportItemService _provideImportItemService;
|
||||||
private readonly ITrackedDownloadAlreadyImported _trackedDownloadAlreadyImported;
|
private readonly ITrackedDownloadAlreadyImported _trackedDownloadAlreadyImported;
|
||||||
|
|
||||||
public CompletedDownloadService(IEventAggregator eventAggregator,
|
public CompletedDownloadService(IEventAggregator eventAggregator,
|
||||||
IHistoryService historyService,
|
IHistoryService historyService,
|
||||||
IProvideImportItemService importItemService,
|
IProvideImportItemService provideImportItemService,
|
||||||
IDownloadedTracksImportService downloadedTracksImportService,
|
IDownloadedTracksImportService downloadedTracksImportService,
|
||||||
IArtistService artistService,
|
IArtistService artistService,
|
||||||
ITrackedDownloadAlreadyImported trackedDownloadAlreadyImported)
|
ITrackedDownloadAlreadyImported trackedDownloadAlreadyImported)
|
||||||
{
|
{
|
||||||
_eventAggregator = eventAggregator;
|
_eventAggregator = eventAggregator;
|
||||||
_historyService = historyService;
|
_historyService = historyService;
|
||||||
_importItemService = importItemService;
|
_provideImportItemService = provideImportItemService;
|
||||||
_downloadedTracksImportService = downloadedTracksImportService;
|
_downloadedTracksImportService = downloadedTracksImportService;
|
||||||
_artistService = artistService;
|
_artistService = artistService;
|
||||||
_trackedDownloadAlreadyImported = trackedDownloadAlreadyImported;
|
_trackedDownloadAlreadyImported = trackedDownloadAlreadyImported;
|
||||||
|
@ -52,7 +52,7 @@ public void Check(TrackedDownload trackedDownload)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
trackedDownload.ImportItem = _importItemService.ProvideImportItem(trackedDownload.DownloadItem, trackedDownload.ImportItem);
|
SetImportItem(trackedDownload);
|
||||||
|
|
||||||
// Only process tracked downloads that are still downloading
|
// Only process tracked downloads that are still downloading
|
||||||
if (trackedDownload.State != TrackedDownloadState.Downloading)
|
if (trackedDownload.State != TrackedDownloadState.Downloading)
|
||||||
|
@ -68,18 +68,8 @@ public void Check(TrackedDownload trackedDownload)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var downloadItemOutputPath = trackedDownload.ImportItem.OutputPath;
|
if (!ValidatePath(trackedDownload))
|
||||||
|
|
||||||
if (downloadItemOutputPath.IsEmpty)
|
|
||||||
{
|
{
|
||||||
trackedDownload.Warn("Download doesn't contain intermediate path, Skipping.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((OsInfo.IsWindows && !downloadItemOutputPath.IsWindowsPath) ||
|
|
||||||
(OsInfo.IsNotWindows && !downloadItemOutputPath.IsUnixPath))
|
|
||||||
{
|
|
||||||
trackedDownload.Warn("[{0}] is not a valid local path. You may need a Remote Path Mapping.", downloadItemOutputPath);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +94,13 @@ public void Check(TrackedDownload trackedDownload)
|
||||||
|
|
||||||
public void Import(TrackedDownload trackedDownload)
|
public void Import(TrackedDownload trackedDownload)
|
||||||
{
|
{
|
||||||
|
SetImportItem(trackedDownload);
|
||||||
|
|
||||||
|
if (!ValidatePath(trackedDownload))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
trackedDownload.State = TrackedDownloadState.Importing;
|
trackedDownload.State = TrackedDownloadState.Importing;
|
||||||
|
|
||||||
var outputPath = trackedDownload.ImportItem.OutputPath.FullPath;
|
var outputPath = trackedDownload.ImportItem.OutputPath.FullPath;
|
||||||
|
@ -169,5 +166,30 @@ public void Import(TrackedDownload trackedDownload)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetImportItem(TrackedDownload trackedDownload)
|
||||||
|
{
|
||||||
|
trackedDownload.ImportItem = _provideImportItemService.ProvideImportItem(trackedDownload.DownloadItem, trackedDownload.ImportItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ValidatePath(TrackedDownload trackedDownload)
|
||||||
|
{
|
||||||
|
var downloadItemOutputPath = trackedDownload.ImportItem.OutputPath;
|
||||||
|
|
||||||
|
if (downloadItemOutputPath.IsEmpty)
|
||||||
|
{
|
||||||
|
trackedDownload.Warn("Download doesn't contain intermediate path, Skipping.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((OsInfo.IsWindows && !downloadItemOutputPath.IsWindowsPath) ||
|
||||||
|
(OsInfo.IsNotWindows && !downloadItemOutputPath.IsUnixPath))
|
||||||
|
{
|
||||||
|
trackedDownload.Warn("[{0}] is not a valid local path. You may need a Remote Path Mapping.", downloadItemOutputPath);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue