@@ -63,31 +63,63 @@ protected function execute(InputInterface $input, OutputInterface $output): int
63
63
$ version = strval ($ input ->getArgument ('version ' ));
64
64
$ archiveFileFull = $ this ->tempDirectory . "/factorio_ $ {version}_full.tar.xz " ;
65
65
$ archiveFileHeadless = $ this ->tempDirectory . "/factorio_ $ {version}_headless.tar.xz " ;
66
+ $ tempDirectoryFull = $ this ->tempDirectory . "/factorio_ $ {version}_full " ;
67
+ $ tempDirectoryHeadless = $ this ->tempDirectory . "/factorio_ $ {version}_headless " ;
66
68
67
69
$ this ->console ->writeHeadline ("Downloading and installing Factorio version {$ version }" );
68
70
69
71
$ this ->console ->writeAction ('Downloading full variant of Factorio ' );
70
- $ fullProcess = $ this ->factorioDownloadService ->createFactorioDownloadProcess (
72
+ $ downloadFullProcess = $ this ->factorioDownloadService ->createFactorioDownloadProcess (
71
73
FactorioDownloadService::VARIANT_FULL ,
72
74
$ version ,
73
75
$ archiveFileFull ,
74
76
);
75
- $ fullProcess ->start ();
77
+ $ downloadFullProcess ->start ();
76
78
77
79
$ this ->console ->writeAction ('Downloading headless variant of Factorio ' );
78
- $ headlessProcess = $ this ->factorioDownloadService ->createFactorioDownloadProcess (
80
+ $ downloadHeadlessProcess = $ this ->factorioDownloadService ->createFactorioDownloadProcess (
79
81
FactorioDownloadService::VARIANT_HEADLESS ,
80
82
$ version ,
81
83
$ archiveFileHeadless ,
82
84
);
83
- $ headlessProcess ->run ();
84
-
85
+ $ downloadHeadlessProcess ->run ();
86
+ if ($ downloadHeadlessProcess ->getExitCode () !== 0 ) {
87
+ $ this ->console ->writeMessage ('<fg=red>Download of headless version failed!</> ' );
88
+ return 1 ;
89
+ }
85
90
$ this ->console ->writeAction ('Extracting headless variant of Factorio ' );
86
- $ this ->factorioDownloadService ->extractFactorio ($ archiveFileHeadless , $ this ->headlessFactorioDirectory );
91
+ $ extractHeadlessProcess = $ this ->factorioDownloadService ->createFactorioExtractProcess (
92
+ $ archiveFileHeadless ,
93
+ $ tempDirectoryHeadless ,
94
+ );
95
+ $ extractHeadlessProcess ->run ();
96
+ if ($ extractHeadlessProcess ->getExitCode () !== 0 ) {
97
+ $ this ->console ->writeMessage ('<fg=red>Extracting headless version failed!</> ' );
98
+ return 1 ;
99
+ }
100
+
101
+ $ downloadFullProcess ->wait ();
102
+ if ($ downloadFullProcess ->getExitCode () !== 0 ) {
103
+ $ this ->console ->writeMessage ('<fg=red>Download of full version failed!</> ' );
104
+ return 1 ;
105
+ }
87
106
88
- $ fullProcess ->wait ();
89
107
$ this ->console ->writeAction ('Extracting full variant of Factorio ' );
90
- $ this ->factorioDownloadService ->extractFactorio ($ archiveFileFull , $ this ->fullFactorioDirectory );
108
+ $ extractFullProcess = $ this ->factorioDownloadService ->createFactorioExtractProcess (
109
+ $ archiveFileFull ,
110
+ $ tempDirectoryFull ,
111
+ );
112
+ $ extractFullProcess ->run ();
113
+ if ($ extractFullProcess ->getExitCode () !== 0 ) {
114
+ $ this ->console ->writeMessage ('<fg=red>Extracting full version failed!</> ' );
115
+ return 1 ;
116
+ }
117
+
118
+ $ this ->console ->writeAction ('Switching Factorio releases ' );
119
+ $ this ->fileSystem ->remove ($ this ->headlessFactorioDirectory );
120
+ $ this ->fileSystem ->rename ($ tempDirectoryHeadless , $ this ->headlessFactorioDirectory );
121
+ $ this ->fileSystem ->remove ($ this ->fullFactorioDirectory );
122
+ $ this ->fileSystem ->rename ($ tempDirectoryFull , $ this ->fullFactorioDirectory );
91
123
92
124
$ this ->console ->writeAction ('Cleaning up ' );
93
125
$ this ->fileSystem ->remove ($ archiveFileHeadless );
0 commit comments