Browse Source

fix local library locking when adding paths (#492)

pull/493/head
Jason Dove 4 years ago committed by GitHub
parent
commit
3a40d6ce77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 5
      ErsatzTV.Application/Libraries/Commands/CreateLocalLibraryHandler.cs
  3. 5
      ErsatzTV.Application/Libraries/Commands/UpdateLocalLibraryHandler.cs

1
CHANGELOG.md

@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- Properly fix database incompatibility introduced with v0.2.4-alpha and partially fixed with v0.2.5-alpha
- The proper fix requires rebuilding all playouts, which will happen on startup after upgrading
- Fix local library locking/progress display when adding paths
### Added
- Add *experimental* `Songs` local libraries

5
ErsatzTV.Application/Libraries/Commands/CreateLocalLibraryHandler.cs

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
@ -37,7 +36,7 @@ namespace ErsatzTV.Application.Libraries.Commands @@ -37,7 +36,7 @@ namespace ErsatzTV.Application.Libraries.Commands
CreateLocalLibrary request,
CancellationToken cancellationToken)
{
await using TvContext dbContext = _dbContextFactory.CreateDbContext();
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, LocalLibrary> validation = await Validate(dbContext, request);
return await validation.Apply(localLibrary => PersistLocalLibrary(dbContext, localLibrary));
}

5
ErsatzTV.Application/Libraries/Commands/UpdateLocalLibraryHandler.cs

@ -43,7 +43,7 @@ namespace ErsatzTV.Application.Libraries.Commands @@ -43,7 +43,7 @@ namespace ErsatzTV.Application.Libraries.Commands
UpdateLocalLibrary request,
CancellationToken cancellationToken)
{
await using TvContext dbContext = _dbContextFactory.CreateDbContext();
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
Validation<BaseError, Parameters> validation = await Validate(dbContext, request);
return await validation.Apply(parameters => UpdateLocalLibrary(dbContext, parameters));
}
@ -53,7 +53,6 @@ namespace ErsatzTV.Application.Libraries.Commands @@ -53,7 +53,6 @@ namespace ErsatzTV.Application.Libraries.Commands
(LocalLibrary existing, LocalLibrary incoming) = parameters;
existing.Name = incoming.Name;
// toAdd
var toAdd = incoming.Paths
.Filter(p => existing.Paths.All(ep => NormalizePath(ep.Path) != NormalizePath(p.Path)))
.ToList();
@ -77,7 +76,7 @@ namespace ErsatzTV.Application.Libraries.Commands @@ -77,7 +76,7 @@ namespace ErsatzTV.Application.Libraries.Commands
_searchIndex.Commit();
}
if (toAdd.Count > 0 || toRemove.Count > 0 && _entityLocker.LockLibrary(existing.Id))
if ((toAdd.Count > 0 || toRemove.Count > 0) && _entityLocker.LockLibrary(existing.Id))
{
await _workerChannel.WriteAsync(new ForceScanLocalLibrary(existing.Id));
}

Loading…
Cancel
Save