@@ -380,7 +380,8 @@ public async Task<Bitmap> GetThumbnailAsync(DriveSegment driveSegment)
380380 await ConnectAsync ( ) ;
381381
382382 Bitmap thumbnail = null ;
383- var drive = new DirectoryInfo ( Path . GetDirectoryName ( driveSegment . FrontVideo . File . FullName ) ) . Name ;
383+ var videoFile = driveSegment . FrontVideoQuick ?? driveSegment . FrontVideo ;
384+ var drive = new DirectoryInfo ( Path . GetDirectoryName ( videoFile . File . FullName ) ) . Name ;
384385 var cachedThumbnail = Path . Combine ( TempDirectory , drive + ".jpg" ) ;
385386
386387
@@ -389,7 +390,6 @@ public async Task<Bitmap> GetThumbnailAsync(DriveSegment driveSegment)
389390 bool quickVideo = driveSegment . FrontVideoQuick != null ;
390391 var offset = 0 ;
391392
392- var videoFile = driveSegment . FrontVideoQuick ?? driveSegment . FrontVideo ;
393393 var imageBuffer = quickVideo ? new byte [ 10000 ] : new byte [ 200000 ] ;
394394
395395 await using ( var sftpFileStream = SftpClient . OpenRead ( videoFile . File . FullName ) )
@@ -407,7 +407,7 @@ public async Task<Bitmap> GetThumbnailAsync(DriveSegment driveSegment)
407407 try
408408 {
409409 await FFMpegArguments
410- . FromPipeInput ( new StreamPipeSource ( msInput ) , options => options . WithFramerate ( 20 ) . ForceFormat ( quickVideo ? "mpegts" : "rawvideo" ) )
410+ . FromPipeInput ( new StreamPipeSource ( msInput ) , options => options . WithFramerate ( 20 ) )
411411 . OutputToPipe ( new StreamPipeSink ( msOutput ) , options =>
412412 options . WithVideoCodec ( VideoCodec . Png )
413413 . WithFrameOutputCount ( 1 )
@@ -591,9 +591,7 @@ public async Task<IEnumerable<Firmware>> GetFirmwareVersions(IProgress<int> prog
591591
592592 var firmwares = new List < Firmware > ( ) ;
593593
594- var drives = GetDrives ( ) ;
595-
596- foreach ( var drive in drives )
594+ await foreach ( var drive in GetDrivesAsync ( ) )
597595 {
598596 foreach ( var driveSegment in drive . Segments . OrderBy ( segment => segment . Index ) )
599597 {
@@ -668,7 +666,7 @@ public async Task<GpxFile> GenerateGpxFileAsync(Drive drive, IProgress<int> prog
668666
669667 public async IAsyncEnumerable < Drive > GetDrivesAsync ( [ EnumeratorCancellation ] CancellationToken cancellationToken = default ( CancellationToken ) )
670668 {
671- await ConnectAsync ( ) ;
669+ await ConnectAsync ( cancellationToken ) ;
672670
673671 IOrderedEnumerable < IGrouping < DateTime , SftpFile > > directoryListing ;
674672
@@ -680,7 +678,7 @@ public async Task<GpxFile> GenerateGpxFileAsync(Drive drive, IProgress<int> prog
680678 {
681679 return DateTime . ParseExact ( dir . Name . AsSpan ( ) . Slice ( 0 , 20 ) , "yyyy-MM-dd--HH-mm-ss" , CultureInfo . InvariantCulture , DateTimeStyles . AssumeUniversal ) . ToUniversalTime ( ) ;
682680 } )
683- . OrderBy ( dir =>
681+ . OrderByDescending ( dir =>
684682 {
685683 var date = dir . Key ;
686684 return date ;
0 commit comments