Browse Source

fix removing emby and jellyfin libraries (#1011)

* fix removing jellyfin and emby libraries

* remove unneeded change
pull/1017/head
Jason Dove 3 years ago committed by GitHub
parent
commit
7a87fb1c2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CHANGELOG.md
  2. 26
      ErsatzTV.Infrastructure/Data/Repositories/MediaSourceRepository.cs
  3. 4
      ErsatzTV.sln

3
CHANGELOG.md

@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Fixed
- Fix removing Jellyfin and Emby libraries that have been deleted from the source media server
### Added
- Add audio stream selector scripts for episodes and movies
- This will let you customize which audio stream is selected for playback

26
ErsatzTV.Infrastructure/Data/Repositories/MediaSourceRepository.cs

@ -178,9 +178,16 @@ public class MediaSourceRepository : IMediaSourceRepository @@ -178,9 +178,16 @@ public class MediaSourceRepository : IMediaSourceRepository
dbContext.JellyfinLibraries.Add(add);
}
dbContext.JellyfinLibraries.RemoveRange(toDelete);
var libraryIds = toDelete.Map(l => l.Id).ToList();
List<int> deletedMediaIds = await dbContext.MediaItems
.Filter(mi => libraryIds.Contains(mi.LibraryPath.LibraryId))
.Map(mi => mi.Id)
.ToListAsync();
List<int> ids = await DisableJellyfinLibrarySync(toDelete.Map(l => l.Id).ToList());
foreach (JellyfinLibrary delete in toDelete)
{
dbContext.JellyfinLibraries.Remove(delete);
}
foreach (JellyfinLibrary incoming in toUpdate)
{
@ -214,7 +221,7 @@ public class MediaSourceRepository : IMediaSourceRepository @@ -214,7 +221,7 @@ public class MediaSourceRepository : IMediaSourceRepository
await dbContext.SaveChangesAsync();
return ids;
return deletedMediaIds;
}
public async Task<List<int>> UpdateLibraries(
@ -231,9 +238,16 @@ public class MediaSourceRepository : IMediaSourceRepository @@ -231,9 +238,16 @@ public class MediaSourceRepository : IMediaSourceRepository
dbContext.EmbyLibraries.Add(add);
}
dbContext.EmbyLibraries.RemoveRange(toDelete);
var libraryIds = toDelete.Map(l => l.Id).ToList();
List<int> deletedMediaIds = await dbContext.MediaItems
.Filter(mi => libraryIds.Contains(mi.LibraryPath.LibraryId))
.Map(mi => mi.Id)
.ToListAsync();
List<int> ids = await DisableEmbyLibrarySync(toDelete.Map(l => l.Id).ToList());
foreach (EmbyLibrary delete in toDelete)
{
dbContext.EmbyLibraries.Remove(delete);
}
foreach (EmbyLibrary incoming in toUpdate)
{
@ -267,7 +281,7 @@ public class MediaSourceRepository : IMediaSourceRepository @@ -267,7 +281,7 @@ public class MediaSourceRepository : IMediaSourceRepository
await dbContext.SaveChangesAsync();
return ids;
return deletedMediaIds;
}
public async Task<Unit> UpdatePathReplacements(

4
ErsatzTV.sln

@ -27,8 +27,8 @@ Global @@ -27,8 +27,8 @@ Global
{E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Release|Any CPU.Build.0 = Release|Any CPU
{E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug No Sync|Any CPU.ActiveCfg = Debug No Sync|Any CPU
{E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug No Sync|Any CPU.Build.0 = Debug No Sync|Any CPU
{E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug|Any CPU.ActiveCfg = Debug No Sync|Any CPU
{E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug|Any CPU.Build.0 = Debug No Sync|Any CPU
{E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E83551AD-27E4-46E5-AD06-5B0DF797B8FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C56FC23D-B863-401E-8E7C-E92BC307AFC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C56FC23D-B863-401E-8E7C-E92BC307AFC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C56FC23D-B863-401E-8E7C-E92BC307AFC1}.Release|Any CPU.ActiveCfg = Release|Any CPU

Loading…
Cancel
Save