|
15 | 15 | // You should have received a copy of the GNU General Public License
|
16 | 16 | // along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
|
17 | 17 |
|
18 |
| -using Ionic.Zip; |
19 | 18 | using Newtonsoft.Json;
|
20 | 19 | using ORTS.Common;
|
21 | 20 | using ORTS.Settings;
|
|
24 | 23 | using System.ComponentModel;
|
25 | 24 | using System.Diagnostics;
|
26 | 25 | using System.IO;
|
| 26 | +using System.IO.Compression; |
27 | 27 | using System.Linq;
|
28 | 28 | using System.Net;
|
29 | 29 | using System.Runtime.InteropServices;
|
@@ -413,14 +413,22 @@ void DownloadUpdate(int progressMin, int progressLength)
|
413 | 413 |
|
414 | 414 | void ExtractUpdate(int progressMin, int progressLength)
|
415 | 415 | {
|
416 |
| - using (var zip = ZipFile.Read(FileUpdateStage)) |
| 416 | + using (var zip = ZipFile.OpenRead(FileUpdateStage)) |
417 | 417 | {
|
418 |
| - zip.ExtractProgress += (object sender, ExtractProgressEventArgs e) => |
| 418 | + for (var index = 0; index < zip.Entries.Count; index++) |
419 | 419 | {
|
420 |
| - if (e.EventType == ZipProgressEventType.Extracting_BeforeExtractEntry) |
421 |
| - TriggerApplyProgressChanged(progressMin + progressLength * e.EntriesExtracted / e.EntriesTotal); |
422 |
| - }; |
423 |
| - zip.ExtractAll(PathUpdateStage, ExtractExistingFileAction.OverwriteSilently); |
| 420 | + TriggerApplyProgressChanged(progressMin + progressLength * index / zip.Entries.Count); |
| 421 | + |
| 422 | + var absolutePath = Path.GetFullPath(Path.Combine(PathUpdateStage, zip.Entries[index].FullName)); |
| 423 | + if (!absolutePath.StartsWith(PathUpdateStage)) |
| 424 | + throw new IOException("Invalid update: attempting to extract outside staging area"); |
| 425 | + |
| 426 | + if (Path.GetFileName(absolutePath).Length > 0) |
| 427 | + { |
| 428 | + Directory.CreateDirectory(Path.GetDirectoryName(absolutePath)); |
| 429 | + zip.Entries[index].ExtractToFile(absolutePath, true); |
| 430 | + } |
| 431 | + } |
424 | 432 | }
|
425 | 433 |
|
426 | 434 | File.Delete(FileUpdateStage);
|
|
0 commit comments