From bffd9559f745fbe662faad78e4d9fec6551d266c Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 30 Jun 2019 02:51:04 +0100 Subject: [PATCH] fixes file saving & code format --- src/Yavsc/Services/LiveProcessor.cs | 2 -- .../ViewModels/Streaming/LiveCastHandler.cs | 19 +++++++++---------- src/cli/Makefile | 3 +++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Yavsc/Services/LiveProcessor.cs b/src/Yavsc/Services/LiveProcessor.cs index 90df86ac..08501a98 100644 --- a/src/Yavsc/Services/LiveProcessor.cs +++ b/src/Yavsc/Services/LiveProcessor.cs @@ -153,9 +153,7 @@ namespace Yavsc.Services buffer = new byte[Constants.WebSocketsMaxBufLen+16]; sBuffer = new ArraySegment(buffer); received = await liveHandler.Socket.ReceiveAsync(sBuffer, liveHandler.TokenSource.Token); - count = (received.Count<4)? 0 : buffer[0]*256*1024 +buffer[1]*1024+buffer[2]*256 + buffer[3]; - _logger.LogInformation($"Received bytes : {count}"); _logger.LogInformation($"Is the end : {received.EndOfMessage}"); if (received.Count<=4 || count > Constants.WebSocketsMaxBufLen) { diff --git a/src/Yavsc/ViewModels/Streaming/LiveCastHandler.cs b/src/Yavsc/ViewModels/Streaming/LiveCastHandler.cs index fed9c822..630e7c85 100644 --- a/src/Yavsc/ViewModels/Streaming/LiveCastHandler.cs +++ b/src/Yavsc/ViewModels/Streaming/LiveCastHandler.cs @@ -51,13 +51,12 @@ namespace Yavsc.ViewModels.Streaming usage -= fi.Length; } logger.LogInformation("Opening the file"); - using (var dest = fi.OpenWrite()) + using (var dest = fi.Open(FileMode.Create, FileAccess.Write, FileShare.Read)) { logger.LogInformation("Appening to file"); - while (queue.Count>0) + while (!isEndOfInput() || queue.Count>0) { - while (queue.Count>0) - { + if (queue.Count>0) { var buffer = queue.Dequeue(); int count = buffer.Array[0]*256*1024 +buffer.Array[1]*1024+buffer.Array[2]*256 + buffer.Array[3]; @@ -72,14 +71,14 @@ namespace Yavsc.ViewModels.Streaming else { var packetInfo = JsonConvert.SerializeObject(buffer); logger.LogError($"didn“t wrote {count} bytes from {buffer.Array.Length}!\n{packetInfo}"); - } - if (usage >= user.DiskQuota) break; + } } - if (isEndOfInput()) break; if (usage >= user.DiskQuota) break; - logger.LogInformation($"Waitting 200ms."); - await Task.Delay(100); - logger.LogInformation($"Done waiting"); + if (queue.Count==0 && !isEndOfInput()) { + logger.LogInformation($"Waitting 200ms."); + await Task.Delay(100); + logger.LogInformation($"Done waiting"); + } } user.DiskUsage = usage; dest.Close(); diff --git a/src/cli/Makefile b/src/cli/Makefile index b4bf283c..58c29a5b 100644 --- a/src/cli/Makefile +++ b/src/cli/Makefile @@ -12,11 +12,14 @@ msbuild-restore: check: run + project.lock.json: project.json dnu restore @# fixing package id reference case, to System.Xml, from package NJsonSchema.CodeGeneration.CSharp sed 's/System.XML/System.Xml/' project.lock.json > project.lock.json.new && mv project.lock.json.new project.lock.json +restore: project.lock.json + $(BINTARGETPATH): project.lock.json run: $(BINTARGETPATH)