more scanning improvements related to media file table (#2754)
This commit is contained in:
@@ -417,6 +417,7 @@ public class EmbyMovieRepository : IEmbyMovieRepository
|
||||
MediaFile file = version.MediaFiles.Head();
|
||||
MediaFile incomingFile = incomingVersion.MediaFiles.Head();
|
||||
file.Path = incomingFile.Path;
|
||||
file.PathHash = PathUtils.GetPathHash(incomingFile.Path);
|
||||
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
@@ -895,6 +895,7 @@ public class EmbyTelevisionRepository(
|
||||
MediaFile file = version.MediaFiles.Head();
|
||||
MediaFile incomingFile = incomingVersion.MediaFiles.Head();
|
||||
file.Path = incomingFile.Path;
|
||||
file.PathHash = PathUtils.GetPathHash(incomingFile.Path);
|
||||
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
|
||||
@@ -379,6 +379,7 @@ public class JellyfinMovieRepository : IJellyfinMovieRepository
|
||||
MediaFile file = version.MediaFiles.Head();
|
||||
MediaFile incomingFile = incomingVersion.MediaFiles.Head();
|
||||
file.Path = incomingFile.Path;
|
||||
file.PathHash = PathUtils.GetPathHash(incomingFile.Path);
|
||||
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
@@ -932,6 +932,7 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository
|
||||
|
||||
// delete old chapters
|
||||
await dbContext.MediaChapters
|
||||
.TagWithCallSite()
|
||||
.Where(c => c.MediaVersionId == version.Id)
|
||||
.ExecuteDeleteAsync(cancellationToken);
|
||||
|
||||
@@ -942,11 +943,15 @@ public class JellyfinTelevisionRepository : IJellyfinTelevisionRepository
|
||||
ch.MediaVersionId = version.Id;
|
||||
}
|
||||
|
||||
// always update media file path
|
||||
// always update media file path (and hash)
|
||||
MediaFile incomingFile = incomingVersion.MediaFiles.Head();
|
||||
await dbContext.MediaFiles
|
||||
.TagWithCallSite()
|
||||
.Where(mf => mf.MediaVersionId == version.Id)
|
||||
.ExecuteUpdateAsync(mf => mf.SetProperty(f => f.Path, incomingFile.Path), cancellationToken);
|
||||
.ExecuteUpdateAsync(
|
||||
mf => mf.SetProperty(f => f.Path, incomingFile.Path)
|
||||
.SetProperty(f => f.PathHash, PathUtils.GetPathHash(incomingFile.Path)),
|
||||
cancellationToken);
|
||||
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
|
||||
|
||||
@@ -171,8 +171,8 @@ public class MediaItemRepository(
|
||||
@"select coalesce(EpisodeId, MovieId, MusicVideoId, OtherVideoId, SongId, ImageId, RemoteStreamId) as MediaItemId
|
||||
from MediaVersion MV
|
||||
inner join MediaFile MF on MV.Id = MF.MediaVersionId
|
||||
where MF.Path = @Path",
|
||||
new { Path = path })
|
||||
where MF.PathHash = @PathHash",
|
||||
new { PathHash = PathUtils.GetPathHash(path) })
|
||||
.Map(Optional);
|
||||
|
||||
foreach (int mediaItemId in maybeMediaItemId)
|
||||
|
||||
@@ -118,12 +118,11 @@ public class MetadataRepository(IDbContextFactory<TvContext> dbContextFactory) :
|
||||
|
||||
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync();
|
||||
Option<MediaVersion> maybeVersion = await dbContext.MediaVersions
|
||||
.TagWithCallSite()
|
||||
.Include(v => v.Streams)
|
||||
.Include(v => v.Chapters)
|
||||
.Include(v => v.MediaFiles)
|
||||
.OrderBy(v => v.Id)
|
||||
.SingleOrDefaultAsync(v => v.Id == mediaVersionId)
|
||||
.Map(Optional);
|
||||
.SingleOrDefaultAsync(v => v.Id == mediaVersionId);
|
||||
|
||||
return await maybeVersion.Match(
|
||||
async existing =>
|
||||
|
||||
Reference in New Issue
Block a user