Check which LOCATE version is supported regardless of the next block on resume.

This commit is contained in:
2019-05-01 19:37:44 +01:00
parent a5e8218c20
commit 03f7fb7a00

View File

@@ -400,12 +400,55 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
bool canLocate = true;
bool canLocateLong = false;
bool canLocate = false;
UpdateStatus?.Invoke("Positioning tape to block 1.");
dumpLog.WriteLine("Positioning tape to block 1");
sense = dev.Locate16(out senseBuf, 1, dev.Timeout, out _);
if(!sense)
{
sense = dev.ReadPositionLong(out cmdBuf, out senseBuf, dev.Timeout, out _);
if(!sense)
{
ulong position = Swapping.Swap(BitConverter.ToUInt64(cmdBuf, 8));
if(position == 1)
{
canLocateLong = true;
UpdateStatus?.Invoke("LOCATE LONG works.");
dumpLog.WriteLine("LOCATE LONG works.");
}
}
}
sense = dev.Locate(out senseBuf, 1, dev.Timeout, out _);
if(!sense)
{
sense = dev.ReadPosition(out cmdBuf, out senseBuf, dev.Timeout, out _);
if(!sense)
{
ulong position = Swapping.Swap(BitConverter.ToUInt32(cmdBuf, 8));
if(position == 1)
{
canLocate = true;
UpdateStatus?.Invoke("LOCATE works.");
dumpLog.WriteLine("LOCATE works.");
}
}
}
if(resume.NextBlock > 0)
{
UpdateStatus?.Invoke($"Positioning tape to block {resume.NextBlock}.");
dumpLog.WriteLine("Positioning tape to block {0}.", resume.NextBlock);
if(resume.NextBlock > uint.MaxValue)
if(canLocateLong)
{
sense = dev.Locate16(out senseBuf, resume.NextBlock, dev.Timeout, out _);
@@ -421,15 +464,14 @@ namespace DiscImageChef.Core.Devices.Dumping
.WriteLine("Could not check current position, unable to resume. If you want to continue use force.");
StoppingErrorMessage
?.Invoke("Could not check current position, unable to resume. If you want to continue use force.");
return;
}
else
{
dumpLog
.WriteLine("Could not check current position, unable to resume. Dumping from the start.");
ErrorMessage
?.Invoke("Could not check current position, unable to resume. Dumping from the start.");
canLocate = false;
}
canLocateLong = false;
}
else
{
@@ -443,15 +485,14 @@ namespace DiscImageChef.Core.Devices.Dumping
.WriteLine("Current position is not as expected, unable to resume. If you want to continue use force.");
StoppingErrorMessage
?.Invoke("Current position is not as expected, unable to resume. If you want to continue use force.");
return;
}
else
{
dumpLog
.WriteLine("Current position is not as expected, unable to resume. Dumping from the start.");
ErrorMessage
?.Invoke("Current position is not as expected, unable to resume. Dumping from the start.");
canLocate = false;
}
canLocateLong = false;
}
}
}
@@ -463,16 +504,15 @@ namespace DiscImageChef.Core.Devices.Dumping
.WriteLine("Cannot reposition tape, unable to resume. If you want to continue use force.");
StoppingErrorMessage
?.Invoke("Cannot reposition tape, unable to resume. If you want to continue use force.");
return;
}
else
{
dumpLog.WriteLine("Cannot reposition tape, unable to resume. Dumping from the start.");
ErrorMessage?.Invoke("Cannot reposition tape, unable to resume. Dumping from the start.");
canLocate = false;
canLocateLong = false;
}
}
}
else
else if(canLocate)
{
sense = dev.Locate(out senseBuf, (uint)resume.NextBlock, dev.Timeout, out _);
@@ -488,16 +528,15 @@ namespace DiscImageChef.Core.Devices.Dumping
.WriteLine("Could not check current position, unable to resume. If you want to continue use force.");
StoppingErrorMessage
?.Invoke("Could not check current position, unable to resume. If you want to continue use force.");
return;
}
else
{
dumpLog
.WriteLine("Could not check current position, unable to resume. Dumping from the start.");
ErrorMessage
?.Invoke("Could not check current position, unable to resume. Dumping from the start.");
canLocate = false;
}
}
else
{
ulong position = Swapping.Swap(BitConverter.ToUInt32(cmdBuf, 4));
@@ -510,9 +549,9 @@ namespace DiscImageChef.Core.Devices.Dumping
.WriteLine("Current position is not as expected, unable to resume. If you want to continue use force.");
StoppingErrorMessage
?.Invoke("Current position is not as expected, unable to resume. If you want to continue use force.");
return;
}
else
{
dumpLog
.WriteLine("Current position is not as expected, unable to resume. Dumping from the start.");
ErrorMessage
@@ -521,7 +560,6 @@ namespace DiscImageChef.Core.Devices.Dumping
}
}
}
}
else
{
if(!force)
@@ -530,19 +568,34 @@ namespace DiscImageChef.Core.Devices.Dumping
.WriteLine("Cannot reposition tape, unable to resume. If you want to continue use force.");
StoppingErrorMessage
?.Invoke("Cannot reposition tape, unable to resume. If you want to continue use force.");
return;
}
else
{
dumpLog.WriteLine("Cannot reposition tape, unable to resume. Dumping from the start.");
ErrorMessage?.Invoke("Cannot reposition tape, unable to resume. Dumping from the start.");
canLocate = false;
}
}
else
{
if(!force)
{
dumpLog.WriteLine("Cannot reposition tape, unable to resume. If you want to continue use force.");
StoppingErrorMessage
?.Invoke("Cannot reposition tape, unable to resume. If you want to continue use force.");
return;
}
dumpLog.WriteLine("Cannot reposition tape, unable to resume. Dumping from the start.");
ErrorMessage?.Invoke("Cannot reposition tape, unable to resume. Dumping from the start.");
canLocate = false;
}
}
if(!canLocate)
{
sense = canLocateLong
? dev.Locate16(out senseBuf, false, 0, 0, dev.Timeout, out duration)
: dev.Locate(out senseBuf, false, 0, 0, dev.Timeout, out duration);
do
{
Thread.Sleep(1000);
@@ -554,8 +607,8 @@ namespace DiscImageChef.Core.Devices.Dumping
(fxSense.Value.ASCQ == 0x1A || fxSense.Value.ASCQ == 0x19));
// And yet, did not rewind!
if(fxSense.HasValue && (fxSense.Value.ASC == 0x00 && fxSense.Value.ASCQ != 0x04 ||
fxSense.Value.ASC != 0x00))
if(fxSense.HasValue &&
(fxSense.Value.ASC == 0x00 && fxSense.Value.ASCQ != 0x04 || fxSense.Value.ASC != 0x00))
{
StoppingErrorMessage?.Invoke("Drive could not rewind, please correct. Sense follows..." +
Environment.NewLine + strSense);
@@ -564,7 +617,6 @@ namespace DiscImageChef.Core.Devices.Dumping
fxSense.Value.ASC, fxSense.Value.ASCQ);
return;
}
}
bool ret = (outputPlugin as IWritableTapeImage).SetTape();
// Cannot set image to tape mode
@@ -805,7 +857,7 @@ namespace DiscImageChef.Core.Devices.Dumping
(double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration);
#region Error handling
if(resume.BadBlocks.Count > 0 && !aborted && retryPasses > 0 && canLocate)
if(resume.BadBlocks.Count > 0 && !aborted && retryPasses > 0 && (canLocate || canLocateLong))
{
int pass = 1;
bool forward = false;
@@ -839,7 +891,7 @@ namespace DiscImageChef.Core.Devices.Dumping
UpdateStatus?.Invoke($"Positioning tape to block {badBlock}.");
dumpLog.WriteLine($"Positioning tape to block {badBlock}.");
if(badBlock > uint.MaxValue)
if(canLocateLong)
{
sense = dev.Locate16(out senseBuf, resume.NextBlock, dev.Timeout, out _);