Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyangwx committed May 27, 2024
1 parent 4a1845a commit 356841a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 35 deletions.
1 change: 0 additions & 1 deletion LTFSCopyGUI/ApplicationEvents.vb
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ dataDir:{dataDir}
Case "-copy"
CheckUAC(e)
Me.MainForm = New TapeCopy()

Case "-gt"
If i < param.Count - 2 Then
Dim Num1 As Byte = Byte.Parse(param(i + 1))
Expand Down
2 changes: 1 addition & 1 deletion LTFSCopyGUI/LTFSConfigurator.vb
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ Public Class LTFSConfigurator
SyncLock TapeUtils.SCSIOperationLock
TapeUtils.OpenTapeDrive(ConfTapeDrive, handle)
TapeUtils._TapeSCSIIOCtlUnmanaged(handle, cdb, 6, data, 0, 2, 60000, sense)
TapeUtils.CloseTapeDrive(ConfTapeDrive)
TapeUtils.CloseTapeDrive(handle)
End SyncLock
Marshal.FreeHGlobal(cdb)
Marshal.FreeHGlobal(data)
Expand Down
50 changes: 25 additions & 25 deletions LTFSCopyGUI/LTFSWriter.resx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAG
CwAAAk1TRnQBSQFMAgEBBAEAAdwBCgHcAQoBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CwAAAk1TRnQBSQFMAgEBBAEAAewBCgHsAQoBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
Expand Down Expand Up @@ -452,7 +452,7 @@
<value>696, 18</value>
</metadata>
<data name="提取ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="提取ToolStripMenuItem.Text" xml:space="preserve">
<value>提取</value>
Expand All @@ -476,52 +476,52 @@
<value>仅验证</value>
</data>
<data name="校验ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="校验ToolStripMenuItem.Text" xml:space="preserve">
<value>校验</value>
</data>
<data name="移动到索引区ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="移动到索引区ToolStripMenuItem.Text" xml:space="preserve">
<value>移动到索引区</value>
</data>
<data name="定位到起始块ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="定位到起始块ToolStripMenuItem.Text" xml:space="preserve">
<value>定位到起始块</value>
</data>
<data name="ToolStripSeparator2.Size" type="System.Drawing.Size, System.Drawing">
<value>177, 6</value>
<value>169, 6</value>
</data>
<data name="剪切文件ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="剪切文件ToolStripMenuItem.Text" xml:space="preserve">
<value>剪切文件</value>
</data>
<data name="粘贴选中ToolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="粘贴选中ToolStripMenuItem1.Text" xml:space="preserve">
<value>粘贴选中</value>
</data>
<data name="重命名文件ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="重命名文件ToolStripMenuItem.Text" xml:space="preserve">
<value>重命名文件</value>
</data>
<data name="重命名目录ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="重命名目录ToolStripMenuItem.Text" xml:space="preserve">
<value>重命名目录</value>
</data>
<data name="ToolStripSeparator3.Size" type="System.Drawing.Size, System.Drawing">
<value>177, 6</value>
<value>169, 6</value>
</data>
<data name="导入文件ToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down Expand Up @@ -554,25 +554,25 @@
</value>
</data>
<data name="导入文件ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="导入文件ToolStripMenuItem.Text" xml:space="preserve">
<value>导入文件</value>
</data>
<data name="添加文件ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="添加文件ToolStripMenuItem.Text" xml:space="preserve">
<value>添加文件</value>
</data>
<data name="添加目录ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="添加目录ToolStripMenuItem.Text" xml:space="preserve">
<value>添加目录</value>
</data>
<data name="新建目录ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="新建目录ToolStripMenuItem.Text" xml:space="preserve">
<value>新建目录</value>
Expand All @@ -590,43 +590,43 @@
<value>跳过符号链接</value>
</data>
<data name="选项ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="选项ToolStripMenuItem.Text" xml:space="preserve">
<value>选项</value>
</data>
<data name="ToolStripSeparator4.Size" type="System.Drawing.Size, System.Drawing">
<value>177, 6</value>
<value>169, 6</value>
</data>
<data name="删除文件ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="删除文件ToolStripMenuItem.Text" xml:space="preserve">
<value>删除文件</value>
</data>
<data name="删除目录ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="删除目录ToolStripMenuItem.Text" xml:space="preserve">
<value>删除目录</value>
</data>
<data name="ToolStripSeparator8.Size" type="System.Drawing.Size, System.Drawing">
<value>177, 6</value>
<value>169, 6</value>
</data>
<data name="生成标签ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="生成标签ToolStripMenuItem.Text" xml:space="preserve">
<value>生成标签</value>
</data>
<data name="设置标签ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="设置标签ToolStripMenuItem.Text" xml:space="preserve">
<value>设置标签</value>
</data>
<data name="文件详情ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="文件详情ToolStripMenuItem.Text" xml:space="preserve">
<value>文件详情</value>
Expand Down Expand Up @@ -656,13 +656,13 @@
<value>XAttr</value>
</data>
<data name="复制信息到剪贴板ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>172, 22</value>
</data>
<data name="复制信息到剪贴板ToolStripMenuItem.Text" xml:space="preserve">
<value>复制信息到剪贴板</value>
</data>
<data name="ContextMenuStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>181, 468</value>
<value>173, 446</value>
</data>
<data name="&gt;&gt;ContextMenuStrip1.Name" xml:space="preserve">
<value>ContextMenuStrip1</value>
Expand Down
31 changes: 24 additions & 7 deletions LTFSCopyGUI/LTFSWriter.vb
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,9 @@ Public Class LTFSWriter
Public MaxCapacity As Long = 0
Public CapacityLogPage As TapeUtils.PageData

Public Sub RefreshCapacity()
Dim logdata As Byte()
logdata = TapeUtils.LogSense(TapeDrive, &H31, PageControl:=1)
Public Function RefreshCapacity() As Long()
Dim result(3) As Long
Dim logdata As Byte() = TapeUtils.LogSense(TapeDrive, &H31, PageControl:=1)
Invoke(Sub()
Try
If CapacityLogPage Is Nothing Then
Expand Down Expand Up @@ -1039,6 +1039,8 @@ Public Class LTFSWriter
Else
ToolStripStatusLabel2.BackgroundImage = GetProgressImage(MaxCapacity - cap1, MaxCapacity, Color.FromArgb(255, 127, 127))
End If
result(2) = max1 - cap1
result(3) = max1
Else
MaxCapacity = max0
If MaxCapacity = 0 Then MaxCapacity = TapeUtils.MAMAttribute.FromTapeDrive(TapeDrive, 0, 1, 0).AsNumeric
Expand All @@ -1050,6 +1052,8 @@ Public Class LTFSWriter
ToolStripStatusLabel2.BackgroundImage = GetProgressImage(MaxCapacity - cap0, MaxCapacity, Color.FromArgb(255, 127, 127))
End If
End If
result(0) = max0 - cap0
result(1) = max0
If My.Settings.LTFSWriter_ShowLoss Then
ToolStripStatusLabel2.Text &= $" Loss:{IOManager.FormatSize(loss)}"
ToolStripStatusLabel2.ToolTipText &= $" Loss:{IOManager.FormatSize(loss)}"
Expand All @@ -1059,8 +1063,8 @@ Public Class LTFSWriter
PrintMsg(My.Resources.ResText_RCErr, TooltipText:=ex.ToString)
End Try
End Sub)

End Sub
Return result
End Function
Public Function GetCapacityMegaBytes() As Long
If ExtraPartitionCount > 0 Then
Return TapeUtils.MAMAttribute.FromTapeDrive(TapeDrive, 0, 0, 1).AsNumeric
Expand Down Expand Up @@ -2108,7 +2112,8 @@ Public Class LTFSWriter
'RefreshDisplay()
End If
End Sub
Public Sub AddFileOrDir(d As ltfsindex.directory, Paths As String(), Optional ByVal overwrite As Boolean = False, Optional ByVal exceptExtention As String() = Nothing)
Public Sub AddFileOrDir(d As ltfsindex.directory, Paths As String(), Optional ByVal overwrite As Boolean = False,
Optional ByVal exceptExtention As String() = Nothing)
Dim th As New Threading.Thread(
Sub()
StopFlag = False
Expand Down Expand Up @@ -3285,6 +3290,7 @@ Public Class LTFSWriter
PrintMsg(My.Resources.ResText_RI)
PrintMsg($"Position = {GetPos.ToString()}", LogOnly:=True)
Dim tmpf As String = $"{Application.StartupPath}\LCG_{Now.ToString("yyyyMMdd_HHmmss.fffffff")}.tmp"

TapeUtils.ReadToFileMark(TapeDrive, tmpf, plabel.blocksize)
PrintMsg($"Position = {GetPos.ToString()}", LogOnly:=True)
PrintMsg(My.Resources.ResText_AI)
Expand Down Expand Up @@ -3525,7 +3531,15 @@ Public Class LTFSWriter
End While
'nop
TapeUtils.ReadPosition(TapeDrive)
Dim MaxExtraPartitionAllowed As Byte = TapeUtils.ModeSense(TapeDrive, &H11)(2)
Dim modedata As Byte() = TapeUtils.ModeSense(TapeDrive, &H11)
Dim MaxExtraPartitionAllowed As Byte
If modedata(1) = 0 Then
MaxExtraPartitionAllowed = modedata(2)
ElseIf modedata.Length > 10 Then
MaxExtraPartitionAllowed = modedata(2 + 8)
Else
MaxExtraPartitionAllowed = 0
End If
If MaxExtraPartitionAllowed > 1 Then MaxExtraPartitionAllowed = 1
Barcode = TapeUtils.ReadBarcode(TapeDrive)
Dim VolumeLabel As String = ""
Expand Down Expand Up @@ -5155,6 +5169,9 @@ Public Class LTFSWriter
If Not isStarted Then Exit Sub
frm.Invoke(Sub() ButtonStart.Enabled = False)
frm.Invoke(Sub() frm.Text = $"Writing")
Dim cap As Long() = RefreshCapacity()
Dim cap1 As Long
If cap(3) > 0 Then cap1 = cap(2) Else cap1 = cap(0)
Invoke(Sub()
AddFileOrDir(schema._directory(0), pathlist.ToArray(), 覆盖已有文件ToolStripMenuItem.Checked, filter)
End Sub)
Expand Down
2 changes: 1 addition & 1 deletion LTFSCopyGUI/TapeUtils.vb
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ Public Class TapeUtils
Return Locate(TapeDrive, CULng(BlockAddress), Partition, DestType)
End Function
Public Shared Function Locate(TapeDrive As String, BlockAddress As ULong, Partition As ltfsindex.PartitionLabel, DestType As LocateDestType)
Return Locate(TapeDrive:=TapeDrive, BlockAddress:=BlockAddress, Partition:=Partition, DestType:=DestType)
Return Locate(TapeDrive:=TapeDrive, BlockAddress:=BlockAddress, Partition:=CByte(Partition), DestType:=DestType)
End Function
Public Shared Function Locate(TapeDrive As String, BlockAddress As UInt64, Partition As Byte, ByVal DestType As LocateDestType) As UInt16
SyncLock SCSIOperationLock
Expand Down

0 comments on commit 356841a

Please sign in to comment.