mirror of
https://github.com/oMaN-Rod/nxDumpFuse.git
synced 2024-11-22 18:26:40 +00:00
Catch fuse error if output file is already open by another process
This commit is contained in:
parent
21720adfae
commit
e53e074ff6
1 changed files with 45 additions and 34 deletions
|
@ -122,6 +122,8 @@ namespace nxDumpFuse.Services
|
||||||
Log(FuseSimpleLogType.Information, $"Fusing {inputFiles.Count} parts to {_outputFilePath} ({totalFileLength.ToMb()}MB)");
|
Log(FuseSimpleLogType.Information, $"Fusing {inputFiles.Count} parts to {_outputFilePath} ({totalFileLength.ToMb()}MB)");
|
||||||
|
|
||||||
_sw.Start();
|
_sw.Start();
|
||||||
|
try
|
||||||
|
{
|
||||||
await using var outputStream = File.Create(_outputFilePath!);
|
await using var outputStream = File.Create(_outputFilePath!);
|
||||||
foreach (var inputFilePath in inputFiles)
|
foreach (var inputFilePath in inputFiles)
|
||||||
{
|
{
|
||||||
|
@ -133,7 +135,8 @@ namespace nxDumpFuse.Services
|
||||||
await using var inputStream = File.OpenRead(inputFilePath);
|
await using var inputStream = File.OpenRead(inputFilePath);
|
||||||
var fileLength = inputStream.Length;
|
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)
|
while ((currentBlockSize = inputStream.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
{
|
{
|
||||||
|
@ -150,13 +153,14 @@ namespace nxDumpFuse.Services
|
||||||
{
|
{
|
||||||
Log(FuseSimpleLogType.Error, e.Message);
|
Log(FuseSimpleLogType.Error, e.Message);
|
||||||
_sw.Stop();
|
_sw.Stop();
|
||||||
Update(0,0,0,0,0,true);
|
Update(0, 0, 0, 0, 0, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var progress = totalBytes * 100.0 / totalFileLength;
|
var progress = totalBytes * 100.0 / totalFileLength;
|
||||||
var progressPart = currentBytes * 100.0 / fileLength;
|
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);
|
Update(count, inputFiles.Count, progress, progressPart, copySpeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,5 +169,12 @@ namespace nxDumpFuse.Services
|
||||||
_sw.Stop();
|
_sw.Stop();
|
||||||
Update(0, 0, 0, 0, 0, true);
|
Update(0, 0, 0, 0, 0, true);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log(FuseSimpleLogType.Error, e.Message);
|
||||||
|
_sw.Stop();
|
||||||
|
Update(0, 0, 0, 0, 0, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue