50
50
import me .itzg .helpers .errors .InvalidParameterException ;
51
51
import me .itzg .helpers .fabric .FabricLauncherInstaller ;
52
52
import me .itzg .helpers .files .Manifests ;
53
+ import me .itzg .helpers .files .ReactiveFileUtils ;
53
54
import me .itzg .helpers .files .ResultsFileWriter ;
54
55
import me .itzg .helpers .forge .ForgeInstaller ;
55
56
import me .itzg .helpers .forge .ForgeInstallerResolver ;
@@ -763,10 +764,15 @@ private Mono<PathWithInfo> downloadAndPostProcess(
763
764
private Mono <DownloadOrResolveResult > buildRetryableDownload (InstallContext context ,
764
765
CurseForgeMod modInfo , CurseForgeFile cfFile , boolean isWorld , Path outputSubdir
765
766
) {
767
+ final Path outputFile = resolveOutputFile (outputSubdir , cfFile );
768
+
766
769
// use defer so that the download mono is rebuilt on each retry
767
770
return Mono .defer (() ->
768
771
downloadOrResolveFile (context , modInfo , isWorld , outputSubdir , cfFile )
769
772
.checkpoint ()
773
+ .onErrorResume (throwable ->
774
+ ReactiveFileUtils .removeFailedDownload (throwable , outputFile )
775
+ )
770
776
)
771
777
// retry the deferred part above if one of the expected failure cases
772
778
.retryWhen (
@@ -778,8 +784,10 @@ private Mono<DownloadOrResolveResult> buildRetryableDownload(InstallContext con
778
784
throwable instanceof ChannelException
779
785
)
780
786
.doBeforeRetry (retrySignal ->
781
- log .warn ("Retrying to download {} @ {}:{}" ,
782
- cfFile .getFileName (), modInfo .getName (), cfFile .getDisplayName ()
787
+ log .warn ("Retry #{} download of {} @ {}:{} due to {}" ,
788
+ retrySignal .totalRetries () + 1 ,
789
+ cfFile .getFileName (), modInfo .getName (), cfFile .getDisplayName (),
790
+ retrySignal .failure ().getClass ().getSimpleName ()
783
791
)
784
792
)
785
793
);
@@ -799,7 +807,7 @@ static class DownloadOrResolveResult {
799
807
private Mono <DownloadOrResolveResult > downloadOrResolveFile (InstallContext context , CurseForgeMod modInfo ,
800
808
boolean isWorld , Path outputSubdir , CurseForgeFile cfFile
801
809
) {
802
- final Path outputFile = outputSubdir . resolve ( cfFile . getFileName () );
810
+ final Path outputFile = resolveOutputFile ( outputSubdir , cfFile );
803
811
804
812
// Will try to locate an existing file by alternate names that browser might create,
805
813
// but only for non-world files of the modpack
@@ -829,6 +837,10 @@ private Mono<DownloadOrResolveResult> downloadOrResolveFile(InstallContext conte
829
837
}
830
838
}
831
839
840
+ private static @ NotNull Path resolveOutputFile (Path outputSubdir , CurseForgeFile cfFile ) {
841
+ return outputSubdir .resolve (cfFile .getFileName ());
842
+ }
843
+
832
844
/**
833
845
* @return Mono.error with {@link FileHashInvalidException} when not valid
834
846
*/
0 commit comments