@@ -616,7 +616,8 @@ const copyFilesLogic = createLogic({
616
616
return ;
617
617
}
618
618
619
- const successfulFiles : string [ ] = [ ] ;
619
+ const newlyCachedFiles : string [ ] = [ ] ;
620
+ const extendedExpirationFiles : string [ ] = [ ] ;
620
621
const failedFiles : string [ ] = [ ] ;
621
622
622
623
Object . entries ( cacheStatuses ) . forEach ( ( [ fileId , status ] ) => {
@@ -625,21 +626,44 @@ const copyFilesLogic = createLogic({
625
626
status === "DOWNLOAD_IN_PROGRESS" ||
626
627
status === "DOWNLOAD_STARTED"
627
628
) {
628
- successfulFiles . push ( fileId ) ;
629
+ const file = fileDetails . find ( ( f ) => f . id === fileId ) ;
630
+ const isAlreadyCached = file ?. annotations . some (
631
+ ( { name, values } ) =>
632
+ name === "Should Be in Local Cache" && values [ 0 ] === true
633
+ ) ;
634
+ ( isAlreadyCached ? extendedExpirationFiles : newlyCachedFiles ) . push ( fileId ) ;
629
635
} else {
630
636
failedFiles . push ( fileId ) ;
631
637
}
632
638
} ) ;
633
639
634
- // Dispatch net success message. (Assuming some files were successful)
635
- if ( successfulFiles . length > 0 ) {
640
+ // Dispatch files queued for download
641
+ if ( newlyCachedFiles . length > 0 ) {
642
+ const count = newlyCachedFiles . length ;
643
+ const fileLabel = count === 1 ? "file was" : "files were" ;
636
644
dispatch (
637
645
interaction . actions . processSuccess (
638
646
"moveFilesSuccess" ,
639
- `${ successfulFiles . length } out of ${
640
- Object . keys ( cacheStatuses ) . length
641
- } files were successfully queued for download to NAS (Vast) from cloud.
642
- Files will be available in the NAS after downloads finish asynchronously`
647
+ `${ count } ${ fileLabel } successfully queued for download to NAS (VAST) from the cloud.
648
+ ${
649
+ count === 1 ? "It will be" : "They will be"
650
+ } available in the NAS after the download${
651
+ count === 1 ? " finishes" : "s finish"
652
+ } asynchronously.`
653
+ )
654
+ ) ;
655
+ }
656
+
657
+ // Dispatch files with extended expiration dates.
658
+ if ( extendedExpirationFiles . length > 0 ) {
659
+ const count = extendedExpirationFiles . length ;
660
+ const fileLabel = count === 1 ? "file's" : "files'" ;
661
+ dispatch (
662
+ interaction . actions . processSuccess (
663
+ "extendFilesExpirationSuccess" ,
664
+ `${ count } ${ fileLabel } expiration ${
665
+ count === 1 ? "date has" : "dates have"
666
+ } been extended.`
643
667
)
644
668
) ;
645
669
}
0 commit comments