1
0
Fork 0
mirror of https://github.com/oMaN-Rod/nxDumpFuse.git synced 2024-11-22 10:16:40 +00:00

Catch fuse error if output file is already open by another process

This commit is contained in:
Omar 2021-11-02 14:00:12 -04:00
parent 21720adfae
commit e53e074ff6

View file

@ -122,6 +122,8 @@ namespace nxDumpFuse.Services
Log(FuseSimpleLogType.Information, $"Fusing {inputFiles.Count} parts to {_outputFilePath} ({totalFileLength.ToMb()}MB)");
_sw.Start();
try
{
await using var outputStream = File.Create(_outputFilePath!);
foreach (var inputFilePath in inputFiles)
{
@ -133,7 +135,8 @@ namespace nxDumpFuse.Services
await using var inputStream = File.OpenRead(inputFilePath);
var fileLength = inputStream.Length;
Log(FuseSimpleLogType.Information, $"Fusing file part {++count}-> {inputFilePath} ({fileLength.ToMb()}MB)");
Log(FuseSimpleLogType.Information,
$"Fusing file part {++count}-> {inputFilePath} ({fileLength.ToMb()}MB)");
while ((currentBlockSize = inputStream.Read(buffer, 0, buffer.Length)) > 0)
{
@ -156,7 +159,8 @@ namespace nxDumpFuse.Services
var progress = totalBytes * 100.0 / totalFileLength;
var progressPart = currentBytes * 100.0 / fileLength;
if(_sw.ElapsedMilliseconds >= 1000) copySpeed = totalBytes / _sw.ElapsedMilliseconds.ToSeconds();
if (_sw.ElapsedMilliseconds >= 1000)
copySpeed = totalBytes / _sw.ElapsedMilliseconds.ToSeconds();
Update(count, inputFiles.Count, progress, progressPart, copySpeed);
}
}
@ -165,5 +169,12 @@ namespace nxDumpFuse.Services
_sw.Stop();
Update(0, 0, 0, 0, 0, true);
}
catch (Exception e)
{
Log(FuseSimpleLogType.Error, e.Message);
_sw.Stop();
Update(0, 0, 0, 0, 0, true);
}
}
}
}