diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-03-20 04:02:28 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-03-20 04:02:28 +0200 |
| commit | bb18f573fe3710f2707c6e6053d4ea2e88e9fed0 (patch) | |
| tree | 94ac7e62c16957307a4ca81fbacd6131cc09188c /Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem | |
| parent | 80a71d5c6d692aa8f82cad00578296a927c0d9d4 (diff) | |
| parent | f9d71e8443dfbf2308cc40ab6943297437265d76 (diff) | |
| download | Tango-bb18f573fe3710f2707c6e6053d4ea2e88e9fed0.tar.gz Tango-bb18f573fe3710f2707c6e6053d4ea2e88e9fed0.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs index ffbba2e7a..804ad0036 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Core; using Tango.Core.DI; +using Tango.Core.IO; using Tango.FileSystem; using Tango.FileSystem.Network; using Tango.Integration.ExternalBridge; @@ -29,6 +30,7 @@ namespace Tango.PPC.Common.FileSystem public FileSystemOperationMode Mode { get; set; } public String Id { get; set; } public String Path { get; set; } + public bool IsPathTempZip { get; set; } public FileSystemOperation(FileSystemOperationMode mode, String path) { @@ -109,6 +111,38 @@ namespace Tango.PPC.Common.FileSystem } } + [ExternalBridgeRequestHandlerMethod(typeof(FolderDownloadRequest))] + public async void OnFolderDownloadRequest(FolderDownloadRequest request, String token, ExternalBridgeReceiver receiver) + { + try + { + if (!Directory.Exists(request.Path)) + { + await receiver.SendErrorResponse(new FileNotFoundException("Could not find the specified directory."), token); + return; + } + + var tempFile = TemporaryManager.CreateImaginaryFile(); + + ZipFile.CreateFromDirectory(request.Path, tempFile); + + FileSystemOperation operation = new FileSystemOperation(FileSystemOperationMode.Download, tempFile); + operation.IsPathTempZip = true; + + _operations.Add(operation.Id, operation); + + await receiver.SendGenericResponse(new FileDownloadResponse() + { + OperationId = operation.Id, + Length = new FileInfo(request.Path).Length + }, token); + } + catch (Exception ex) + { + await receiver.SendErrorResponse(ex, token); + } + } + [ExternalBridgeRequestHandlerMethod(typeof(ChunkUploadRequest))] public async void OnChunkUploadRequest(ChunkUploadRequest request, String token, ExternalBridgeReceiver receiver) { @@ -185,6 +219,13 @@ namespace Tango.PPC.Common.FileSystem Directory.Delete(operation.Path, true); } } + else if (operation.IsPathTempZip) + { + if (File.Exists(operation.Path)) + { + File.Delete(operation.Path); + } + } await receiver.SendGenericResponse(new AbortOperationResponse(), token); } |
