diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-05-09 18:07:56 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-05-09 18:07:56 +0300 |
| commit | e1236499b485a69648bea4d7871aa185e5dae745 (patch) | |
| tree | 8cd4ccd7d272c8c4e61d4bd6bcba434eb9522b85 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels | |
| parent | 2a459c79e90a2ade3f1dac1ae4541c0f4d74965c (diff) | |
| download | Tango-e1236499b485a69648bea4d7871aa185e5dae745.tar.gz Tango-e1236499b485a69648bea4d7871aa185e5dae745.zip | |
New TemporaryManager !
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs index 0f6ec8b98..c8b4b6adc 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/UpdateViewVM.cs @@ -13,6 +13,7 @@ using System.Threading.Tasks; using Tango.Core.Commands; using Tango.Core.DI; using Tango.Core.Helpers; +using Tango.Core.IO; using Tango.Logging; using Tango.MachineStudio.Common.Authentication; using Tango.MachineStudio.Common.Navigation; @@ -45,7 +46,7 @@ namespace Tango.MachineStudio.UI.ViewModels private IStudioApplicationManager _application; private IAuthenticationProvider _authentication; private CheckForUpdatesResponse _updateInfo; - private String _newPackageTempFolder; + private TemporaryFolder _newPackageTempFolder; private UpdateStatus _status; public UpdateStatus Status @@ -184,7 +185,7 @@ namespace Tango.MachineStudio.UI.ViewModels Task.Factory.StartNew(() => { - var tempFile = PathHelper.GetTempFilePath() + ".zip"; + var tempFile = TemporaryManager.CreateFile(".zip"); try { @@ -192,7 +193,7 @@ namespace Tango.MachineStudio.UI.ViewModels int fileSize = 0; - using (FileStreamWrapper fs = new FileStreamWrapper(tempFile, FileMode.Create, (current) => + using (FileStreamWrapper fs = new FileStreamWrapper(tempFile.Path, FileMode.Create, (current) => { InvokeUINow(() => { @@ -216,9 +217,10 @@ namespace Tango.MachineStudio.UI.ViewModels Status = UpdateStatus.Updating; - _newPackageTempFolder = PathHelper.GetTempFolderPath(); + _newPackageTempFolder = TemporaryManager.CreateFolder(); + _newPackageTempFolder.Persist = true; - using (ZipFile zip = ZipFile.Read(tempFile)) + using (ZipFile zip = ZipFile.Read(tempFile.Path)) { int currentEntry = 0; @@ -235,7 +237,7 @@ namespace Tango.MachineStudio.UI.ViewModels { Thread.Sleep(10); - string newPath = Path.Combine(_newPackageTempFolder, entry.FileName); + string newPath = Path.Combine(_newPackageTempFolder.Path, entry.FileName); try { @@ -246,7 +248,7 @@ namespace Tango.MachineStudio.UI.ViewModels else { CurrentUpdateFile = Path.GetFileName(entry.FileName); - entry.Extract(_newPackageTempFolder, ExtractExistingFileAction.OverwriteSilently); + entry.Extract(_newPackageTempFolder.Path, ExtractExistingFileAction.OverwriteSilently); } } catch @@ -266,7 +268,7 @@ namespace Tango.MachineStudio.UI.ViewModels } finally { - PathHelper.TryDeleteFile(tempFile); + tempFile.Delete(); } }); } |
