EXtremeZip 2022.1.10 → 2022.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e95d136f6b500f21919530563bb68a39d1bf931517503e040e515f4931d4e4d2
4
- data.tar.gz: 01e73443dac1d6421f82224c7c32d083bceec3d8aa2d924be8a41e9ce087ebc8
3
+ metadata.gz: 8a901704ebb0119ce33eb6456905840c2b4dc6c0b5b59fef45412a1503bf71b9
4
+ data.tar.gz: 7b848ffaf0a33ae060d77f13c12f45b4c686a155d2fca7a86b69bb816d2e3dc3
5
5
  SHA512:
6
- metadata.gz: 1bb94c733314f90974a7633b11fcb29fdebc1da243fd914215d7f94055878edf8892c382db5525a2c8b788f12d3781bf295ec018caea9d7e88b9e8030c2375b6
7
- data.tar.gz: efcb570636ff01c3810ac1634ecae62390b8231b8d6567ddf7de5b4a084a4f6973a5fc32d70ab34f849559ff429e3c33575c722b7e96ebb5c023456f9655c8a1
6
+ metadata.gz: 38a3aa8e8679c4d065df2b21af79c0808f69e6e7756efd4bc68cbdf35d519c5eff0219e3d2541671ff1fe69f5d1688836f27a53c00ed56ce4d417852613609d0
7
+ data.tar.gz: 90b04389278faddbc27977f5e86c8ce468ffbf85aa95177c48a6630eb29e14f3ca540850b84e4cb95617bf487a54fa5566e9e330f309132249953cae7752c12d
@@ -1,20 +1,47 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # require 'pathname'
4
- # require File.dirname(__FILE__)+'/filemessage.pb.rb'
5
3
  require 'victoriafresh'
6
4
  require 'cbor'
7
5
  require 'lzma'
8
6
  require 'get_process_mem'
9
7
 
10
8
  def checkMemoryUsage(lineNumber)
11
- mem = GetProcessMem.new
9
+ mem = GetProcessMem.new
12
10
 
13
- puts("#{lineNumber} , Memory: #{mem.mb}"); # Debug
11
+ puts("#{lineNumber} , Memory: #{mem.mb}"); # Debug
14
12
  end # def checkMemoryUsage
15
13
 
16
- # 根据版本号,提取VFS数据内容
17
- def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion)
14
+
15
+
16
+
17
+ class ExtremeUnZip
18
+ # 根据偏移值来读取压缩块数据列表。
19
+ def readVfsDataList(wholeCbor)
20
+ compressedVfsDataList = [] # 获取压缩后的数据块列表
21
+ startIndix=wholeCbor['vfsDataListStart'] # 初始起始位置。
22
+
23
+ puts "whole length: #{@wholeFileContent.length}, list conent: #{wholeCbor['vfsDataList']}" # Debug
24
+
25
+
26
+ wholeCbor['vfsDataList'].each do |currentBlockInfo| # 一个个块地处理
27
+ length=currentBlockInfo['length'] # 获取长度。
28
+
29
+ currentBlock=@wholeFileContent[startIndix, length] # 读取内容
30
+
31
+ puts "start index: #{startIndix}, length: #{length}, content length: #{currentBlock.length}" # Debug
32
+
33
+ compressedVfsDataList << currentBlock # 加入当前块
34
+
35
+ startIndix+=length # 位移。
36
+ end
37
+
38
+ compressedVfsDataList # 返回 内容
39
+ end
40
+
41
+ # 根据版本号,提取VFS数据内容
42
+
43
+
44
+ def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion)
18
45
  victoriaFreshData = '' # 解压后的数据块整体
19
46
  dataFileName = 'victoriafreshdata.w' # 数据文件名
20
47
  dataFile = {} # 数据文件对象
@@ -31,6 +58,10 @@ def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion)
31
58
  dataFile.close # 关闭文件
32
59
  elsif (fileVersion >= 30) # 30以上版本
33
60
  compressedVfsDataList = wholeCbor['vfsDataList'] # 获取压缩后的数据块列表
61
+
62
+ if (fileVersion>=251) # 251 以上版本。要按照偏移值来读取压缩数据块列表。
63
+ compressedVfsDataList=readVfsDataList(wholeCbor) # 根据偏移值来读取压缩块数据列表。
64
+ end # if (fileVersion>=251) # 251 以上版本
34
65
 
35
66
  puts("data block amont: #{compressedVfsDataList.length}") # Debug
36
67
 
@@ -44,18 +75,12 @@ def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion)
44
75
 
45
76
  begin # 解压
46
77
  currentRawData = LZMA.decompress(currentCompressed) # 解压这一块
47
-
48
78
 
49
79
  dataFile.syswrite(currentRawData) # 写入内容
50
80
  rescue RuntimeError => e # 解压失败
51
81
  puts "Warning: the exz file may be incomplete." # 报告错误。文件可能不完整。
52
82
  end # begin # 解压
53
83
 
54
- # victoriaFreshData=victoriaFreshData+currentRawData #追加
55
- # victoriaFreshData << currentRawData #追加
56
-
57
- #puts("byte size: #{victoriaFreshData.bytesize}") # debug.
58
-
59
84
  dataBlockCounter += 1 # count
60
85
  end # compressedVfsDataList.each do |currentCompressed|
61
86
 
@@ -65,54 +90,21 @@ def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion)
65
90
  dataFileName # 返回解压后的数据块整体
66
91
  end # def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) #根据版本号,提取VFS数据内容
67
92
 
68
- def extractVfsDataWithVersion(wholeCbor, fileVersion) # 根据版本号,提取VFS数据内容
69
- victoriaFreshData = '' # 解压后的数据块整体
70
-
71
- if (fileVersion == 14) # 14版本
72
- compressedVfsData = wholeCbor['vfsData'] # 获取压缩后的数据内容
73
-
74
- victoriaFreshData = LZMA.decompress(compressedVfsData) # 解压缩数据内容
75
- elsif (fileVersion >= 30) # 30以上版本
76
- compressedVfsDataList = wholeCbor['vfsDataList'] # 获取压缩后的数据块列表
77
-
78
- puts("data block amont: #{compressedVfsDataList.length}") # Debug
79
-
80
- dataBlockCounter = 0 # Data block counter
81
-
82
- compressedVfsDataList.each do |currentCompressed| # 一块块地解压
83
- puts("data block counter: #{dataBlockCounter}") # Debug
84
- checkMemoryUsage(34)
85
-
86
- currentRawData = LZMA.decompress(currentCompressed) # 解压这一块
87
-
88
- # victoriaFreshData=victoriaFreshData+currentRawData #追加
89
- victoriaFreshData << currentRawData # 追加
90
-
91
- puts("byte size: #{victoriaFreshData.bytesize}") # debug.
92
-
93
- dataBlockCounter += 1 # count
94
- end # compressedVfsDataList.each do |currentCompressed|
95
- end # if (fileVersion==14) #14版本
96
-
97
- victoriaFreshData # 返回解压后的数据块整体
98
- end # extractVfsDataWithVersion(wholeCbor, fileVersion) #根据版本号,提取VFS数据内容
99
-
100
- class ExtremeUnZip
101
- # 解压
93
+ # 解压
102
94
  def exuz(rootPath)
103
95
  result = true # 解压结果
104
96
 
105
- wholeFileContent = File.read(rootPath) # 最终文件内容
97
+ currentBlockFile = File.new(rootPath, 'rb') # 打开文件
106
98
 
107
- checkMemoryUsage(60)
99
+ @wholeFileContent = currentBlockFile.read # 读取全部内容
108
100
 
109
- puts wholeFileContent.class # debug
101
+ currentBlockFile.close # 关闭文件
110
102
 
111
- wholeCborByteArray = wholeFileContent[4..-1] # 从第5个到末尾
103
+ #@wholeFileContent = File.read(rootPath) # 最终文件内容
112
104
 
113
- # puts wholeCborByteArray #Debug.
105
+ checkMemoryUsage(60)
114
106
 
115
- #/usr/local/share/gems/gems/EXtremeZip-2021.7.8/lib/extremeunzip.zzaqsu.rb:110:in `decode': end of buffer reached (EOFError)
107
+ wholeCborByteArray = @wholeFileContent[4..-1] # 从第5个到末尾
116
108
 
117
109
  begin # 可能出错。
118
110
  options = {:tolerant => true}
@@ -130,23 +122,16 @@ class ExtremeUnZip
130
122
  checkMemoryUsage(90)
131
123
  replyByteArray = LZMA.decompress(compressedVfsMenu) # 解码目录VFS字节数组内容
132
124
 
133
- # puts replyByteArray #Debug
134
-
135
125
  checkMemoryUsage(95)
136
- # victoriaFreshData=extractVfsDataWithVersion(wholeCbor, fileVersion) #根据版本号,提取VFS数据内容
126
+
137
127
  victoriaFreshDataFile = extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) # 根据版本号,提取VFS数据内容
138
128
 
139
- # puts victoriaFreshData #Debug
140
-
141
129
  checkMemoryUsage(100)
142
130
  $clipDownloader = VictoriaFresh.new # 创建下载器。
143
131
 
144
132
  $clipDownloader.releaseFilesExternalDataFile(replyByteArray, victoriaFreshDataFile) # 释放各个文件
145
133
 
146
134
  fileToRemove = File.new(victoriaFreshDataFile) # 要删除的文件
147
-
148
- #File.delete(fileToRemove) # 删除文件
149
-
150
135
  end # if (fileVersion<14) #版本号过小
151
136
 
152
137
  result =true # 解压成功
@@ -33,6 +33,7 @@ class ExtremeZip
33
33
  @clipDownloader.diskMultiFile = true # 写多个磁盘文件
34
34
  @clipDownloader.diskFileName = 'victoriafreshdata.v.' # 磁盘文件名前缀
35
35
  @clipDownloader.diskFlushSize = @dataBlockLength # 磁盘文件大小
36
+ @clipDownloader.ignoreFileName= '.exzignore' # 设置用于指定忽略文件列表的文件名。
36
37
  end # def initialize
37
38
 
38
39
  # 压缩目录数据。
@@ -47,10 +48,14 @@ class ExtremeZip
47
48
 
48
49
  # 加入基本文件信息
49
50
  def addBasicFileInformation
50
- @wholeCbor['version'] = 233 # 文件格式版本号
51
+ @wholeCbor['version'] = 251 # 文件格式版本号
51
52
 
52
53
  uuid = UUID.new # 获取生成器
53
54
  @wholeCbor['uuid'] = uuid.generate # 指定本个压缩包的唯一编号
55
+
56
+ @wholeCbor['website']='https://rubygems.org/gems/EXtremeZip' # 加入网站地址
57
+
58
+ @wholeCbor['vfsDataListStart']=198910 # 压缩 VFS 数据列表起始位置。
54
59
  end # addBasicFileInformation # 加入基本文件信息
55
60
 
56
61
  # 压缩
@@ -71,10 +76,54 @@ class ExtremeZip
71
76
  @wholeCbor['vfsDataList'] = @vfsDataList # 加入数据
72
77
 
73
78
  wholeFileContent = 'exz' + "\0" + @wholeCbor.to_cbor # 追加CBOR字节数组
79
+
80
+ vfsDataListStart=wholeFileContent.length # 按照现在的序列化情况,计算出来的起始位置。
81
+
82
+ while (vfsDataListStart!=@wholeCbor['vfsDataListStart']) # 计算出的偏移不一致
83
+ @wholeCbor['vfsDataListStart']=vfsDataListStart # 使用新的值
84
+ wholeFileContent = 'exz' + "\0" + @wholeCbor.to_cbor # 追加CBOR字节数组
85
+ vfsDataListStart=wholeFileContent.length # 按照现在的序列化情况,计算出来的起始位置。
86
+ end
74
87
 
75
88
  # 写入文件:
76
89
  writeFile(wholeFileContent, victoriaFresh) # 写入文件内容
90
+
91
+ appendVfsDataList victoriaFresh # 追加压缩块列表数据。
77
92
  end # def exz(rootPath)
93
+
94
+ # 写入压缩块文件
95
+ def writeCompressBlock(compressed, processCounter)
96
+ extremeZipOutputFile = File.new("comressed.#{processCounter}.cex", 'wb') # 创建文件
97
+ extremeZipOutputFile.syswrite(compressed) # 写入文件
98
+ extremeZipOutputFile.close # 关闭文件
99
+ end
100
+
101
+ # 追加压缩块列表数据。
102
+ def appendVfsDataList (victoriaFresh)
103
+ extremeZipOutputFile = File.new("#{victoriaFresh['name']}.exz", 'ab') # 打开文件
104
+
105
+ processCounter=0 # 块计数器。
106
+
107
+ @wholeCbor['vfsDataList'].each do
108
+ #extremeZipOutputFile = File.new("comressed.#{processCounter}.cex", 'wb') # 创建文件
109
+
110
+ currentBlockFile = File.new("comressed.#{processCounter}.cex", 'rb') # 打开文件
111
+
112
+ wholeFileContent = currentBlockFile.read # 读取全部内容
113
+
114
+ currentBlockFile.close # 关闭文件
115
+
116
+ #wholeFileContent=File.read("comressed.#{processCounter}.cex", 'rb') # 读取压缩块。
117
+
118
+ puts "wirte file contetn length: #{wholeFileContent.length}" # Debghu
119
+
120
+ extremeZipOutputFile.syswrite(wholeFileContent) # 写入文件
121
+
122
+ processCounter += 1 # 计数
123
+ end
124
+
125
+ extremeZipOutputFile.close # 关闭文件
126
+ end
78
127
 
79
128
  # 写入文件内容
80
129
  def writeFile(wholeFileContent, victoriaFresh)
@@ -91,8 +140,16 @@ class ExtremeZip
91
140
  currentSubProcess=processIdList[processCounter] # 获取子进程对象
92
141
  #processIdList.each do |currentSubProcess|
93
142
  compressed = receiveFromSubProcess(currentSubProcess, responsePipeList, processCounter) # 从子进程中读取数据,并终止子进程
143
+
144
+ #写入当前压缩块到文件系统中去作为缓存。陈欣
145
+ writeCompressBlock(compressed, processCounter) # 写入压缩块文件
146
+
147
+ blockInfo={} # 块信息
148
+ blockInfo['length']=compressed.length # 记录长度
149
+
150
+ puts "block length: #{blockInfo['length']}" # Debug
94
151
 
95
- @vfsDataList << compressed # 加入数据块列表中
152
+ @vfsDataList << blockInfo # 加入数据块列表中
96
153
  checkMemoryUsage(150)
97
154
 
98
155
  processCounter += 1 # 子进程计数
@@ -167,7 +224,6 @@ class ExtremeZip
167
224
 
168
225
  currentResponsePipe.put currentCompressedVfsData # 将压缩后的数据块写入到回复管道中
169
226
 
170
- checkMemoryUsage(125)
171
227
  puts("finished #{Process.pid}") # Debug
172
228
  end # compressInSubProcess(currentBlockData, currentResponsePipe) # 在子进程中具体执行的压缩代码
173
229
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: EXtremeZip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2022.1.10
4
+ version: 2022.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hxcan Cai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-08 00:00:00.000000000 Z
11
+ date: 2022-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cod
@@ -86,20 +86,20 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 2022.1.11
89
+ version: 2022.1.27
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: 2022.1.11
92
+ version: 2022.1.27
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - "~>"
98
98
  - !ruby/object:Gem::Version
99
- version: 2022.1.11
99
+ version: 2022.1.27
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: 2022.1.11
102
+ version: 2022.1.27
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: hx_cbor
105
105
  requirement: !ruby/object:Gem::Requirement