Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyangwx committed Feb 23, 2024
1 parent 39fee35 commit dc342d2
Showing 3 changed files with 99 additions and 92 deletions.
67 changes: 35 additions & 32 deletions LTFSCopyGUI/LTFSWriter.resx
Original file line number Diff line number Diff line change
@@ -126,10 +126,10 @@
<value>9, 28</value>
</data>
<metadata name="ContextMenuStrip3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>1030, 24</value>
<value>1024, 19</value>
</metadata>
<data name="提取ToolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>124, 22</value>
</data>
<data name="提取ToolStripMenuItem1.Text" xml:space="preserve">
<value>提取</value>
@@ -153,37 +153,37 @@
<value>仅验证</value>
</data>
<data name="校验ToolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>124, 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>124, 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>124, 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>124, 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>124, 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>124, 22</value>
</data>
<data name="解压索引ToolStripMenuItem.Text" xml:space="preserve">
<value>解压索引</value>
@@ -193,7 +193,7 @@
<value>False</value>
</data>
<data name="ContextMenuStrip3.Size" type="System.Drawing.Size, System.Drawing">
<value>181, 180</value>
<value>125, 158</value>
</data>
<data name="&gt;&gt;ContextMenuStrip3.Name" xml:space="preserve">
<value>ContextMenuStrip3</value>
@@ -215,7 +215,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAG
CwAAAk1TRnQBSQFMAgEBBAEAAYQBCAGEAQgBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CwAAAk1TRnQBSQFMAgEBBAEAAZQBCAGUAQgBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
@@ -428,7 +428,7 @@
<value>696, 18</value>
</metadata>
<data name="提取ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="提取ToolStripMenuItem.Text" xml:space="preserve">
<value>提取</value>
@@ -452,40 +452,43 @@
<value>仅验证</value>
</data>
<data name="校验ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="校验ToolStripMenuItem.Text" xml:space="preserve">
<value>校验</value>
</data>
<data name="移动到索引区ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="移动到索引区ToolStripMenuItem.Text" xml:space="preserve">
<value>移动到索引区</value>
</data>
<data name="移动到索引区ToolStripMenuItem.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="定位到起始块ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="定位到起始块ToolStripMenuItem.Text" xml:space="preserve">
<value>定位到起始块</value>
</data>
<data name="ToolStripSeparator2.Size" type="System.Drawing.Size, System.Drawing">
<value>169, 6</value>
<value>177, 6</value>
</data>
<data name="重命名文件ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="重命名文件ToolStripMenuItem.Text" xml:space="preserve">
<value>重命名文件</value>
</data>
<data name="重命名目录ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="重命名目录ToolStripMenuItem.Text" xml:space="preserve">
<value>重命名目录</value>
</data>
<data name="ToolStripSeparator3.Size" type="System.Drawing.Size, System.Drawing">
<value>169, 6</value>
<value>177, 6</value>
</data>
<data name="导入文件ToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
@@ -518,25 +521,25 @@
</value>
</data>
<data name="导入文件ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="导入文件ToolStripMenuItem.Text" xml:space="preserve">
<value>导入文件</value>
</data>
<data name="添加文件ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="添加文件ToolStripMenuItem.Text" xml:space="preserve">
<value>添加文件</value>
</data>
<data name="添加目录ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="添加目录ToolStripMenuItem.Text" xml:space="preserve">
<value>添加目录</value>
</data>
<data name="新建目录ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="新建目录ToolStripMenuItem.Text" xml:space="preserve">
<value>新建目录</value>
@@ -554,43 +557,43 @@
<value>跳过符号链接</value>
</data>
<data name="选项ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="选项ToolStripMenuItem.Text" xml:space="preserve">
<value>选项</value>
</data>
<data name="ToolStripSeparator4.Size" type="System.Drawing.Size, System.Drawing">
<value>169, 6</value>
<value>177, 6</value>
</data>
<data name="删除文件ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="删除文件ToolStripMenuItem.Text" xml:space="preserve">
<value>删除文件</value>
</data>
<data name="删除目录ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="删除目录ToolStripMenuItem.Text" xml:space="preserve">
<value>删除目录</value>
</data>
<data name="ToolStripSeparator8.Size" type="System.Drawing.Size, System.Drawing">
<value>169, 6</value>
<value>177, 6</value>
</data>
<data name="生成标签ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="生成标签ToolStripMenuItem.Text" xml:space="preserve">
<value>生成标签</value>
</data>
<data name="设置标签ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="设置标签ToolStripMenuItem.Text" xml:space="preserve">
<value>设置标签</value>
</data>
<data name="文件详情ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="文件详情ToolStripMenuItem.Text" xml:space="preserve">
<value>文件详情</value>
@@ -620,13 +623,13 @@
<value>XAttr</value>
</data>
<data name="复制信息到剪贴板ToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>172, 22</value>
<value>180, 22</value>
</data>
<data name="复制信息到剪贴板ToolStripMenuItem.Text" xml:space="preserve">
<value>复制信息到剪贴板</value>
</data>
<data name="ContextMenuStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>173, 402</value>
<value>181, 424</value>
</data>
<data name="&gt;&gt;ContextMenuStrip1.Name" xml:space="preserve">
<value>ContextMenuStrip1</value>
120 changes: 62 additions & 58 deletions LTFSCopyGUI/LTFSWriter.vb
Original file line number Diff line number Diff line change
@@ -1681,7 +1681,7 @@ Public Class LTFSWriter
th.Start()
End Sub
Private Sub ListView1_DragEnter(sender As Object, e As DragEventArgs) Handles ListView1.DragEnter
If MenuStrip1.Enabled = False Then
If Not AllowOperation OrElse Not MenuStrip1.Enabled Then
PrintMsg(ResText_DragNA.Text)
Exit Sub
End If
@@ -1829,68 +1829,72 @@ Public Class LTFSWriter
Else
If FileIndex.TempObj Is Nothing OrElse TypeOf FileIndex.TempObj IsNot ltfsindex.file.refFile Then FileIndex.TempObj = New ltfsindex.file.refFile()
CType(FileIndex.TempObj, ltfsindex.file.refFile).FileName = FileName
Dim fs As New IO.FileStream(FileName, IO.FileMode.OpenOrCreate, IO.FileAccess.ReadWrite, IO.FileShare.Read, 8388608, IO.FileOptions.Asynchronous)
For Each fe As ltfsindex.file.extent In FileIndex.extentinfo
Dim succ As Boolean = False
Do
Dim BlockAddress As Long = fe.startblock
Dim ByteOffset As Long = fe.byteoffset
Dim FileOffset As Long = fe.fileoffset
Dim Partition As Long = Math.Min(ExtraPartitionCount, fe.partition)
Dim TotalBytes As Long = fe.bytecount
'Dim p As New TapeUtils.PositionData(TapeDrive)
If RestorePosition Is Nothing OrElse RestorePosition.BlockNumber <> BlockAddress OrElse RestorePosition.PartitionNumber <> Partition Then
TapeUtils.Locate(TapeDrive, BlockAddress, Partition, TapeUtils.LocateDestType.Block)
RestorePosition = New TapeUtils.PositionData(TapeDrive)
End If
fs.Seek(FileOffset, IO.SeekOrigin.Begin)
Dim ReadedSize As Long = 0
While (ReadedSize < TotalBytes + ByteOffset) And Not StopFlag
Dim len As Integer = Math.Min(plabel.blocksize, TotalBytes + ByteOffset - ReadedSize)
Dim Data As Byte() = TapeUtils.ReadBlock(TapeDrive, Nothing, len, True)
SyncLock RestorePosition
RestorePosition.BlockNumber += 1
End SyncLock
If Data.Length <> len OrElse len = 0 Then
PrintMsg($"Error reading at p{RestorePosition.PartitionNumber}b{RestorePosition.BlockNumber}: readed length {Data.Length} should be {len}", LogOnly:=True)
succ = False
Exit Do
Dim fs As New IO.FileStream(FileName, IO.FileMode.OpenOrCreate, IO.FileAccess.ReadWrite, IO.FileShare.Read, 8388608, IO.FileOptions.None)
Try
For Each fe As ltfsindex.file.extent In FileIndex.extentinfo
Dim succ As Boolean = False
Do
Dim BlockAddress As Long = fe.startblock
Dim ByteOffset As Long = fe.byteoffset
Dim FileOffset As Long = fe.fileoffset
Dim Partition As Long = Math.Min(ExtraPartitionCount, fe.partition)
Dim TotalBytes As Long = fe.bytecount
'Dim p As New TapeUtils.PositionData(TapeDrive)
If RestorePosition Is Nothing OrElse RestorePosition.BlockNumber <> BlockAddress OrElse RestorePosition.PartitionNumber <> Partition Then
TapeUtils.Locate(TapeDrive, BlockAddress, Partition, TapeUtils.LocateDestType.Block)
RestorePosition = New TapeUtils.PositionData(TapeDrive)
End If
ReadedSize += len
fs.Write(Data, ByteOffset, len - ByteOffset)

Threading.Interlocked.Add(TotalBytesProcessed, len - ByteOffset)
Threading.Interlocked.Add(CurrentBytesProcessed, len - ByteOffset)
ByteOffset = 0
While Pause
Threading.Thread.Sleep(10)
fs.Seek(FileOffset, IO.SeekOrigin.Begin)
Dim ReadedSize As Long = 0
While (ReadedSize < TotalBytes + ByteOffset) And Not StopFlag
Dim len As Integer = Math.Min(plabel.blocksize, TotalBytes + ByteOffset - ReadedSize)
Dim Data As Byte() = TapeUtils.ReadBlock(TapeDrive, Nothing, len, True)
SyncLock RestorePosition
RestorePosition.BlockNumber += 1
End SyncLock
If Data.Length <> len OrElse len = 0 Then
PrintMsg($"Error reading at p{RestorePosition.PartitionNumber}b{RestorePosition.BlockNumber}: readed length {Data.Length} should be {len}", LogOnly:=True, ForceLog:=True)
succ = False
Exit Do
End If
ReadedSize += len
fs.Write(Data, ByteOffset, len - ByteOffset)
Threading.Interlocked.Add(TotalBytesProcessed, len - ByteOffset)
Threading.Interlocked.Add(CurrentBytesProcessed, len - ByteOffset)
ByteOffset = 0
While Pause
Threading.Thread.Sleep(10)
End While
End While
End While
If StopFlag Then
fs.Close()
IO.File.Delete(FileName)
If StopFlag Then
fs.Close()
IO.File.Delete(FileName)
succ = True
Exit Do
End If
succ = True
Exit Do
Loop

If Not succ Then
PrintMsg($"{FileIndex.name}{ResText_RestoreErr.Text}", ForceLog:=True)
Exit For
End If
succ = True
Exit Do
Loop
'If Not TapeUtils.RawDump(TapeDrive, FileName, fe.startblock, fe.byteoffset, fe.fileoffset, Math.Min(ExtraPartitionCount, fe.partition), fe.bytecount, StopFlag, plabel.blocksize,
' Function(BytesReaded As Long)
' Threading.Interlocked.Add(TotalBytesProcessed, BytesReaded)
' Threading.Interlocked.Add(CurrentBytesProcessed, BytesReaded)
' Return StopFlag
' End Function, CreateNew, False) Then
' PrintMsg($"{FileIndex.name}提取出错")
' Exit For
'End If
If StopFlag Then Exit Sub
Next
Catch ex As Exception
PrintMsg($"{FileIndex.name}{ResText_RestoreErr.Text}{ex.ToString}", ForceLog:=True)
End Try

If Not succ Then
PrintMsg($"{FileIndex.name}{ResText_RestoreErr.Text}")
Exit For
End If
'If Not TapeUtils.RawDump(TapeDrive, FileName, fe.startblock, fe.byteoffset, fe.fileoffset, Math.Min(ExtraPartitionCount, fe.partition), fe.bytecount, StopFlag, plabel.blocksize,
' Function(BytesReaded As Long)
' Threading.Interlocked.Add(TotalBytesProcessed, BytesReaded)
' Threading.Interlocked.Add(CurrentBytesProcessed, BytesReaded)
' Return StopFlag
' End Function, CreateNew, False) Then
' PrintMsg($"{FileIndex.name}提取出错")
' Exit For
'End If
If StopFlag Then Exit Sub
Next
fs.Flush()
fs.Close()
Dim finfo As New IO.FileInfo(FileName)
@@ -2010,7 +2014,7 @@ Public Class LTFSWriter
Return a.File.extentinfo(0).startblock.CompareTo(b.File.extentinfo(0).startblock)
End Function))
For i As Integer = 1 To FileList.Count - 1
If FileList(i).File.length = FileList(i - 1).File.length AndAlso FileList(i).File.sha1 = FileList(i - 1).File.sha1 Then
If FileList(i).File.length = FileList(i - 1).File.length AndAlso FileList(i).File.sha1.Length = 40 AndAlso FileList(i).File.sha1 = FileList(i - 1).File.sha1 Then
FileList(i).File.TempObj = FileList(i - 1).File.TempObj
End If
Next
4 changes: 2 additions & 2 deletions LTFSCopyGUI/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
@@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices
' 方法是按如下所示使用“*”: :
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("3.5.0.0")>
<Assembly: AssemblyFileVersion("3.5.0.0")>
<Assembly: AssemblyVersion("3.5.1.0")>
<Assembly: AssemblyFileVersion("3.5.1.0")>
<Assembly: NeutralResourcesLanguage("")>

0 comments on commit dc342d2

Please sign in to comment.