aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-20 04:03:05 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-20 04:03:05 +0200
commitd0dba9752d0a8e787d9ae1d4d25542bd4b386df6 (patch)
treeb71977215c188d65d61fcfb66e982a8363b4d803 /Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem
parent7f0b3b209792cb935b9cfca4542c45318a309717 (diff)
downloadTango-d0dba9752d0a8e787d9ae1d4d25542bd4b386df6.tar.gz
Tango-d0dba9752d0a8e787d9ae1d4d25542bd4b386df6.zip
Implemented priority queues for Transport Layer.
Working on file/folder download.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs41
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);
}