@ -78,16 +78,32 @@ public class OtherVideoFolderScanner : LocalFolderScanner, IOtherVideoFolderScan
var allFolders = new System . Collections . Generic . HashSet < string > ( ) ;
var allFolders = new System . Collections . Generic . HashSet < string > ( ) ;
var folderQueue = new Queue < string > ( ) ;
var folderQueue = new Queue < string > ( ) ;
System . Collections . Generic . HashSet < string > allMissingFiles =
await _l ibraryRepository . FindAllMissingFiles ( libraryPath ) ;
if ( allMissingFiles . Count > 0 )
{
_l ogger . LogDebug (
"Library path {Path} has {Count} missing files" ,
libraryPath . Path ,
allMissingFiles . Count ) ;
}
string normalizedLibraryPath = libraryPath . Path . TrimEnd (
string normalizedLibraryPath = libraryPath . Path . TrimEnd (
Path . DirectorySeparatorChar ,
Path . DirectorySeparatorChar ,
Path . AltDirectorySeparatorChar ) ;
Path . AltDirectorySeparatorChar ) ;
if ( libraryPath . Path ! = normalizedLibraryPath )
if ( libraryPath . Path ! = normalizedLibraryPath )
{
{
_l ogger . LogDebug (
"Normalizing library path from {Original} to {Normalized}" ,
libraryPath . Path ,
normalizedLibraryPath ) ;
await _l ibraryRepository . UpdatePath ( libraryPath , normalizedLibraryPath ) ;
await _l ibraryRepository . UpdatePath ( libraryPath , normalizedLibraryPath ) ;
}
}
if ( ShouldIncludeFolder ( libraryPath . Path ) & & allFolders . Add ( libraryPath . Path ) )
if ( ShouldIncludeFolder ( libraryPath . Path ) & & allFolders . Add ( libraryPath . Path ) )
{
{
_l ogger . LogDebug ( "Adding folder to scanner queue: {Folder}" , libraryPath . Path ) ;
folderQueue . Enqueue ( libraryPath . Path ) ;
folderQueue . Enqueue ( libraryPath . Path ) ;
}
}
@ -96,6 +112,7 @@ public class OtherVideoFolderScanner : LocalFolderScanner, IOtherVideoFolderScan
. Filter ( allFolders . Add )
. Filter ( allFolders . Add )
. OrderBy ( identity ) )
. OrderBy ( identity ) )
{
{
_l ogger . LogDebug ( "Adding folder to scanner queue: {Folder}" , folder ) ;
folderQueue . Enqueue ( folder ) ;
folderQueue . Enqueue ( folder ) ;
}
}
@ -133,6 +150,7 @@ public class OtherVideoFolderScanner : LocalFolderScanner, IOtherVideoFolderScan
. Filter ( allFolders . Add )
. Filter ( allFolders . Add )
. OrderBy ( identity ) )
. OrderBy ( identity ) )
{
{
_l ogger . LogDebug ( "Adding folder to scanner queue: {Folder}" , subdirectory ) ;
folderQueue . Enqueue ( subdirectory ) ;
folderQueue . Enqueue ( subdirectory ) ;
}
}
@ -142,8 +160,18 @@ public class OtherVideoFolderScanner : LocalFolderScanner, IOtherVideoFolderScan
maybeParentFolder ,
maybeParentFolder ,
otherVideoFolder ) ;
otherVideoFolder ) ;
bool hasMissingFiles = allFiles . Any ( allMissingFiles . Contains ) ;
bool isSameEtag = knownFolder . Etag = = etag & & ! hasMissingFiles ;
_l ogger . LogDebug (
"Scanning other video folder {Folder}; etag {Etag}; last etag {LastEtag}; has missing files {HasMissingFiles}" ,
otherVideoFolder ,
etag ,
knownFolder . Etag ,
hasMissingFiles ) ;
// skip folder if etag matches
// skip folder if etag matches
if ( allFiles . Count = = 0 | | knownFolder . Etag = = etag )
if ( allFiles . Count = = 0 | | isSameE tag)
{
{
continue ;
continue ;
}
}
@ -156,6 +184,8 @@ public class OtherVideoFolderScanner : LocalFolderScanner, IOtherVideoFolderScan
foreach ( string file in allFiles . OrderBy ( identity ) )
foreach ( string file in allFiles . OrderBy ( identity ) )
{
{
_l ogger . LogDebug ( "Processing other video file {File}" , file ) ;
Either < BaseError , MediaItemScanResult < OtherVideo > > maybeVideo = await _ otherVideoRepository
Either < BaseError , MediaItemScanResult < OtherVideo > > maybeVideo = await _ otherVideoRepository
. GetOrAdd ( libraryPath , knownFolder , file )
. GetOrAdd ( libraryPath , knownFolder , file )
. BindT ( video = > UpdateStatistics ( video , ffmpegPath , ffprobePath ) )
. BindT ( video = > UpdateStatistics ( video , ffmpegPath , ffprobePath ) )