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; 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) if(resume.NextBlock > 0)
{ {
UpdateStatus?.Invoke($"Positioning tape to block {resume.NextBlock}."); UpdateStatus?.Invoke($"Positioning tape to block {resume.NextBlock}.");
dumpLog.WriteLine("Positioning tape to block {0}.", 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 _); 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."); .WriteLine("Could not check current position, unable to resume. If you want to continue use force.");
StoppingErrorMessage StoppingErrorMessage
?.Invoke("Could not check current position, unable to resume. If you want to continue use force."); ?.Invoke("Could not check current position, unable to resume. If you want to continue use force.");
return;
} }
else
{
dumpLog dumpLog
.WriteLine("Could not check current position, unable to resume. Dumping from the start."); .WriteLine("Could not check current position, unable to resume. Dumping from the start.");
ErrorMessage ErrorMessage
?.Invoke("Could not check current position, unable to resume. Dumping from the start."); ?.Invoke("Could not check current position, unable to resume. Dumping from the start.");
canLocate = false; canLocateLong = false;
}
} }
else 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."); .WriteLine("Current position is not as expected, unable to resume. If you want to continue use force.");
StoppingErrorMessage StoppingErrorMessage
?.Invoke("Current position is not as expected, unable to resume. If you want to continue use force."); ?.Invoke("Current position is not as expected, unable to resume. If you want to continue use force.");
return;
} }
else
{
dumpLog dumpLog
.WriteLine("Current position is not as expected, unable to resume. Dumping from the start."); .WriteLine("Current position is not as expected, unable to resume. Dumping from the start.");
ErrorMessage ErrorMessage
?.Invoke("Current position is not as expected, unable to resume. Dumping from the start."); ?.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."); .WriteLine("Cannot reposition tape, unable to resume. If you want to continue use force.");
StoppingErrorMessage StoppingErrorMessage
?.Invoke("Cannot reposition tape, unable to resume. If you want to continue use force."); ?.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."); dumpLog.WriteLine("Cannot reposition tape, unable to resume. Dumping from the start.");
ErrorMessage?.Invoke("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 if(canLocate)
else
{ {
sense = dev.Locate(out senseBuf, (uint)resume.NextBlock, dev.Timeout, out _); 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."); .WriteLine("Could not check current position, unable to resume. If you want to continue use force.");
StoppingErrorMessage StoppingErrorMessage
?.Invoke("Could not check current position, unable to resume. If you want to continue use force."); ?.Invoke("Could not check current position, unable to resume. If you want to continue use force.");
return;
} }
else
{
dumpLog dumpLog
.WriteLine("Could not check current position, unable to resume. Dumping from the start."); .WriteLine("Could not check current position, unable to resume. Dumping from the start.");
ErrorMessage ErrorMessage
?.Invoke("Could not check current position, unable to resume. Dumping from the start."); ?.Invoke("Could not check current position, unable to resume. Dumping from the start.");
canLocate = false; canLocate = false;
} }
}
else else
{ {
ulong position = Swapping.Swap(BitConverter.ToUInt32(cmdBuf, 4)); 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."); .WriteLine("Current position is not as expected, unable to resume. If you want to continue use force.");
StoppingErrorMessage StoppingErrorMessage
?.Invoke("Current position is not as expected, unable to resume. If you want to continue use force."); ?.Invoke("Current position is not as expected, unable to resume. If you want to continue use force.");
return;
} }
else
{
dumpLog dumpLog
.WriteLine("Current position is not as expected, unable to resume. Dumping from the start."); .WriteLine("Current position is not as expected, unable to resume. Dumping from the start.");
ErrorMessage ErrorMessage
@@ -521,7 +560,6 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
} }
} }
}
else else
{ {
if(!force) 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."); .WriteLine("Cannot reposition tape, unable to resume. If you want to continue use force.");
StoppingErrorMessage StoppingErrorMessage
?.Invoke("Cannot reposition tape, unable to resume. If you want to continue use force."); ?.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."); dumpLog.WriteLine("Cannot reposition tape, unable to resume. Dumping from the start.");
ErrorMessage?.Invoke("Cannot reposition tape, unable to resume. Dumping from the start."); ErrorMessage?.Invoke("Cannot reposition tape, unable to resume. Dumping from the start.");
canLocate = false; 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 do
{ {
Thread.Sleep(1000); Thread.Sleep(1000);
@@ -554,8 +607,8 @@ namespace DiscImageChef.Core.Devices.Dumping
(fxSense.Value.ASCQ == 0x1A || fxSense.Value.ASCQ == 0x19)); (fxSense.Value.ASCQ == 0x1A || fxSense.Value.ASCQ == 0x19));
// And yet, did not rewind! // And yet, did not rewind!
if(fxSense.HasValue && (fxSense.Value.ASC == 0x00 && fxSense.Value.ASCQ != 0x04 || if(fxSense.HasValue &&
fxSense.Value.ASC != 0x00)) (fxSense.Value.ASC == 0x00 && fxSense.Value.ASCQ != 0x04 || fxSense.Value.ASC != 0x00))
{ {
StoppingErrorMessage?.Invoke("Drive could not rewind, please correct. Sense follows..." + StoppingErrorMessage?.Invoke("Drive could not rewind, please correct. Sense follows..." +
Environment.NewLine + strSense); Environment.NewLine + strSense);
@@ -564,7 +617,6 @@ namespace DiscImageChef.Core.Devices.Dumping
fxSense.Value.ASC, fxSense.Value.ASCQ); fxSense.Value.ASC, fxSense.Value.ASCQ);
return; return;
} }
}
bool ret = (outputPlugin as IWritableTapeImage).SetTape(); bool ret = (outputPlugin as IWritableTapeImage).SetTape();
// Cannot set image to tape mode // Cannot set image to tape mode
@@ -805,7 +857,7 @@ namespace DiscImageChef.Core.Devices.Dumping
(double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration); (double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration);
#region Error handling #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; int pass = 1;
bool forward = false; bool forward = false;
@@ -839,7 +891,7 @@ namespace DiscImageChef.Core.Devices.Dumping
UpdateStatus?.Invoke($"Positioning tape to block {badBlock}."); UpdateStatus?.Invoke($"Positioning tape to block {badBlock}.");
dumpLog.WriteLine($"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 _); sense = dev.Locate16(out senseBuf, resume.NextBlock, dev.Timeout, out _);