Browse Source

properly unlock libraries after failed scans (#574)

pull/575/head
Jason Dove 4 years ago committed by GitHub
parent
commit
0f4219f731
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 39
      ErsatzTV.Application/MediaSources/Commands/ScanLocalLibraryHandler.cs

1
CHANGELOG.md

@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix local folder scanners to properly detect removed/re-added folders with unchanged contents - Fix local folder scanners to properly detect removed/re-added folders with unchanged contents
- Fix double-click startup on mac - Fix double-click startup on mac
- Fix trakt list sync when show does not contain a year - Fix trakt list sync when show does not contain a year
- Properly unlock libraries when a scan is unable to be performed because ffmpeg or ffprobe have not been found
### Added ### Added
- Add trash system for local libraries to maintain collection and schedule integrity through media share outages - Add trash system for local libraries to maintain collection and schedule integrity through media share outages

39
ErsatzTV.Application/MediaSources/Commands/ScanLocalLibraryHandler.cs

@ -160,15 +160,36 @@ namespace ErsatzTV.Application.MediaSources.Commands
return Unit.Default; return Unit.Default;
} }
private async Task<Validation<BaseError, RequestParameters>> Validate(IScanLocalLibrary request) => private async Task<Validation<BaseError, RequestParameters>> Validate(IScanLocalLibrary request)
(await LocalLibraryMustExist(request), await ValidateFFprobePath(), await ValidateFFmpegPath(), await ValidateLibraryRefreshInterval()) {
.Apply( Validation<BaseError, LocalLibrary> libraryResult = await LocalLibraryMustExist(request);
(library, ffprobePath, ffmpegPath, libraryRefreshInterval) => new RequestParameters( Validation<BaseError, string> ffprobePathResult = await ValidateFFprobePath();
library, Validation<BaseError, string> ffmpegPathResult = await ValidateFFmpegPath();
ffprobePath, Validation<BaseError, int> refreshIntervalResult = await ValidateLibraryRefreshInterval();
ffmpegPath,
request.ForceScan, try
libraryRefreshInterval)); {
return (libraryResult, ffprobePathResult, ffmpegPathResult, refreshIntervalResult)
.Apply(
(library, ffprobePath, ffmpegPath, libraryRefreshInterval) => new RequestParameters(
library,
ffprobePath,
ffmpegPath,
request.ForceScan,
libraryRefreshInterval));
}
finally
{
// ensure we unlock the library if any validation is unsuccessful
foreach (LocalLibrary library in libraryResult.SuccessToSeq())
{
if (ffprobePathResult.IsFail || ffmpegPathResult.IsFail || refreshIntervalResult.IsFail)
{
_entityLocker.UnlockLibrary(library.Id);
}
}
}
}
private Task<Validation<BaseError, LocalLibrary>> LocalLibraryMustExist( private Task<Validation<BaseError, LocalLibrary>> LocalLibraryMustExist(
IScanLocalLibrary request) => IScanLocalLibrary request) =>

Loading…
Cancel
Save