EXtremeZip 2022.2.5 → 2022.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a901704ebb0119ce33eb6456905840c2b4dc6c0b5b59fef45412a1503bf71b9
4
- data.tar.gz: 7b848ffaf0a33ae060d77f13c12f45b4c686a155d2fca7a86b69bb816d2e3dc3
3
+ metadata.gz: f274c7112e5fa1cf2379de1a65c7c25b14041431045ab3b519acefac42c9de17
4
+ data.tar.gz: 055ba68656972d056b5102b8e3248c12e78c00382138be2dbdd7762d63d7e640
5
5
  SHA512:
6
- metadata.gz: 38a3aa8e8679c4d065df2b21af79c0808f69e6e7756efd4bc68cbdf35d519c5eff0219e3d2541671ff1fe69f5d1688836f27a53c00ed56ce4d417852613609d0
7
- data.tar.gz: 90b04389278faddbc27977f5e86c8ce468ffbf85aa95177c48a6630eb29e14f3ca540850b84e4cb95617bf487a54fa5566e9e330f309132249953cae7752c12d
6
+ metadata.gz: d0ce3400f2248ea435e52b05e7afec8a27a7dcb97e4ddfd74536302afc460daba0c9dfdc6b11d1f3fea53344c1dc8152ad7cf41933b52f7976936da25a8faf49
7
+ data.tar.gz: f70e13f87ab926df4a6ecae50eaf2231fa547953e8ff665e1e31781be0c3cd88d2a2a4af0c5cb280c4598d0033c8c4e648ee7b4451d7f23092b0e5b02a43cbb2
@@ -92,46 +92,44 @@ end # def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) #根据
92
92
 
93
93
  # 解压
94
94
  def exuz(rootPath)
95
- result = true # 解压结果
96
-
97
- currentBlockFile = File.new(rootPath, 'rb') # 打开文件
95
+ result = true # 解压结果
98
96
 
99
- @wholeFileContent = currentBlockFile.read # 读取全部内容
97
+ currentBlockFile = File.new(rootPath, 'rb') # 打开文件
100
98
 
101
- currentBlockFile.close # 关闭文件
99
+ @wholeFileContent = currentBlockFile.read # 读取全部内容
102
100
 
103
- #@wholeFileContent = File.read(rootPath) # 最终文件内容
101
+ currentBlockFile.close # 关闭文件
104
102
 
105
- checkMemoryUsage(60)
103
+ checkMemoryUsage(60)
106
104
 
107
- wholeCborByteArray = @wholeFileContent[4..-1] # 从第5个到末尾
105
+ wholeCborByteArray = @wholeFileContent[4..-1] # 从第5个到末尾
108
106
 
109
107
  begin # 可能出错。
110
- options = {:tolerant => true}
108
+ options = {:tolerant => true}
111
109
 
112
- wholeCbor = CBOR.decode(wholeCborByteArray, options) # 解码
110
+ wholeCbor = CBOR.decode(wholeCborByteArray, options) # 解码
113
111
 
114
- fileVersion = wholeCbor['version'] # 获取版本号
112
+ fileVersion = wholeCbor['version'] # 获取版本号
115
113
 
116
114
  if (fileVersion < 14) # 版本号过小
117
- checkMemoryUsage(85)
118
- puts 'file version too old' # 报告错误
115
+ checkMemoryUsage(85)
116
+ puts 'file version too old' # 报告错误
119
117
  else # 版本号够大
120
- compressedVfsMenu = wholeCbor['vfsMenu'] # 获取压缩后的目录内容
118
+ compressedVfsMenu = wholeCbor['vfsMenu'] # 获取压缩后的目录内容
121
119
 
122
- checkMemoryUsage(90)
123
- replyByteArray = LZMA.decompress(compressedVfsMenu) # 解码目录VFS字节数组内容
120
+ checkMemoryUsage(90)
121
+ replyByteArray = LZMA.decompress(compressedVfsMenu) # 解码目录VFS字节数组内容
124
122
 
125
- checkMemoryUsage(95)
123
+ checkMemoryUsage(95)
126
124
 
127
- victoriaFreshDataFile = extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) # 根据版本号,提取VFS数据内容
125
+ victoriaFreshDataFile = extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) # 根据版本号,提取VFS数据内容
128
126
 
129
- checkMemoryUsage(100)
130
- $clipDownloader = VictoriaFresh.new # 创建下载器。
127
+ checkMemoryUsage(100)
128
+ $clipDownloader = VictoriaFresh.new # 创建下载器。
131
129
 
132
- $clipDownloader.releaseFilesExternalDataFile(replyByteArray, victoriaFreshDataFile) # 释放各个文件
130
+ $clipDownloader.releaseFilesExternalDataFile(replyByteArray, victoriaFreshDataFile) # 释放各个文件
133
131
 
134
- fileToRemove = File.new(victoriaFreshDataFile) # 要删除的文件
132
+ fileToRemove = File.new(victoriaFreshDataFile) # 要删除的文件
135
133
  end # if (fileVersion<14) #版本号过小
136
134
 
137
135
  result =true # 解压成功
@@ -8,6 +8,7 @@ require 'etc' # cpu amount
8
8
  require 'cod'
9
9
  require 'uuid'
10
10
  require 'get_process_mem'
11
+ require 'pathname'
11
12
 
12
13
  def checkMemoryUsage(lineNumber)
13
14
  mem = GetProcessMem.new
@@ -22,6 +23,7 @@ class ExtremeZip
22
23
  @filePartCounter = 0 # 文件分块计数器
23
24
  @responsePipeList = [] # 任务回复管道列表
24
25
  @processIdList = [] # 子进程编号列表。
26
+ @processTimestamp = Time.new.to_i # 记录进程启动的时间戳。
25
27
 
26
28
  @maxSubProcessAmount = Etc.nprocessors # 获取最大的子进程个数
27
29
 
@@ -57,54 +59,138 @@ class ExtremeZip
57
59
 
58
60
  @wholeCbor['vfsDataListStart']=198910 # 压缩 VFS 数据列表起始位置。
59
61
  end # addBasicFileInformation # 加入基本文件信息
62
+
63
+ def writeStamp(rootPath) # 更新时间戳文件
64
+ directoryPathName=Pathname.new(rootPath) #构造路径名字对象。
65
+ datastore= "#{directoryPathName.expand_path}/.exzstamp" # 配置文件路径
66
+ puts "writing stamp file: #{datastore}" # Debug
67
+
68
+ #stamp = wholeCbor['timestamp'] # 获取时间戳
69
+ stampCbor={} # 时间戳对象。
70
+ stampCbor['timestamp']= @processTimestamp # 设置时间戳。
71
+
72
+ compressed= stampCbor.to_cbor
73
+
74
+ extremeZipOutputFile = File.new(datastore, 'wb') # 创建文件
75
+ extremeZipOutputFile.syswrite(compressed) # 写入文件
76
+ extremeZipOutputFile.close # 关闭文件
77
+
78
+ end # writeStamp # 更新时间戳文件
79
+
80
+ def loadStamp(rootPath) # 读取时间戳阈值。
81
+ stamp=0 # 默认值。
82
+ fileExists=false # 文件是否存在
83
+
84
+ directoryPathName=Pathname.new(rootPath) #构造路径名字对象。
85
+
86
+ isFile=directoryPathName.file? #是否是文件。
87
+
88
+ unless isFile #是文件就跳过。
89
+ #陈欣
90
+
91
+ datastore= "#{directoryPathName.expand_path}/.exzstamp" # 配置文件路径
92
+ puts "reading stamp file: #{datastore}" # Debug
93
+
94
+ begin # 尝试读取。
95
+
96
+ #陈欣
97
+
98
+ currentBlockFile = File.new(datastore, 'rb') # 打开文件
99
+
100
+ fileExists=true # 文件存在
101
+
102
+ stampFileContent = currentBlockFile.read # 读取全部内容
103
+
104
+ currentBlockFile.close # 关闭文件
105
+
106
+ options = {:tolerant => true}
107
+
108
+ wholeCbor = CBOR.decode(stampFileContent, options) # 解码
109
+
110
+ puts wholeCbor # Debug
111
+ puts wholeCbor.inspect # Debug
112
+
113
+ stamp ||= wholeCbor['timestamp'] # 获取时间戳
114
+ #stamp = wholeCbor.try(:[], 'timestamp') # 获取时间戳
115
+
116
+
117
+ rescue Errno::ENOENT, TypeError
118
+
119
+ end
120
+
121
+
122
+ end #unless isFile #是文件就跳过。
123
+
124
+ return stamp, fileExists # 返回时间戳。
125
+ end #loadStamp(rootPath) # 读取时间戳阈值。
60
126
 
61
127
  # 压缩
62
128
  def exz(rootPath)
63
- victoriaFresh, = @clipDownloader.checkOnce(rootPath) # 打包该目录树。
129
+ timestampTHreshold, fileExists=loadStamp(rootPath) # 读取时间戳阈值。
130
+
131
+ #陈欣
132
+
133
+ if (timestampTHreshold > 0) # 有效的时间戳
134
+ @clipDownloader.timestampThreshold=timestampTHreshold # 设置文件时间戳阈值。
135
+ end #if (timestampTHreshold > 0) # 有效的时间戳
136
+
137
+ if fileExists # 存在文件,则表明将要发生增量压缩
138
+ @wholeCbor['incremental']=true # 是增量压缩。
139
+
140
+ end # if fileExists # 存在文件,则表明用户要求增量压缩
64
141
 
65
- @filePartAmount = @clipDownloader.currentDiskFlushSuffix # 获取文件个数
142
+ @wholeCbor['timestamp']=@processTimestamp # 记录进程启动的时间戳。
143
+
144
+ victoriaFresh, = @clipDownloader.checkOnce(rootPath) # 打包该目录树。
66
145
 
67
- compressVfsMenu(victoriaFresh) # 压缩目录数据。
146
+ @filePartAmount = @clipDownloader.currentDiskFlushSuffix # 获取文件个数
68
147
 
69
- addBasicFileInformation # 加入基本文件信息
148
+ compressVfsMenu(victoriaFresh) # 压缩目录数据。
70
149
 
71
- processIdList, responsePipeList = launchSubProcesses # 启动子进程。
150
+ addBasicFileInformation # 加入基本文件信息
72
151
 
73
- receiveCompressedVfsDataList(processIdList, responsePipeList) # 接收压缩后的数据块列表
152
+ processIdList, responsePipeList = launchSubProcesses # 启动子进程。
74
153
 
75
- checkMemoryUsage(155)
76
- @wholeCbor['vfsDataList'] = @vfsDataList # 加入数据
154
+ receiveCompressedVfsDataList(processIdList, responsePipeList) # 接收压缩后的数据块列表
77
155
 
78
- wholeFileContent = 'exz' + "\0" + @wholeCbor.to_cbor # 追加CBOR字节数组
156
+ checkMemoryUsage(155)
157
+ @wholeCbor['vfsDataList'] = @vfsDataList # 加入数据
158
+
159
+ wholeFileContent = 'exz' + "\0" + @wholeCbor.to_cbor # 追加CBOR字节数组
79
160
 
80
- vfsDataListStart=wholeFileContent.length # 按照现在的序列化情况,计算出来的起始位置。
161
+ vfsDataListStart=wholeFileContent.length # 按照现在的序列化情况,计算出来的起始位置。
81
162
 
82
- while (vfsDataListStart!=@wholeCbor['vfsDataListStart']) # 计算出的偏移不一致
83
- @wholeCbor['vfsDataListStart']=vfsDataListStart # 使用新的值
84
- wholeFileContent = 'exz' + "\0" + @wholeCbor.to_cbor # 追加CBOR字节数组
85
- vfsDataListStart=wholeFileContent.length # 按照现在的序列化情况,计算出来的起始位置。
86
- end
163
+ while (vfsDataListStart!=@wholeCbor['vfsDataListStart']) # 计算出的偏移不一致
164
+ @wholeCbor['vfsDataListStart']=vfsDataListStart # 使用新的值
165
+ wholeFileContent = 'exz' + "\0" + @wholeCbor.to_cbor # 追加CBOR字节数组
166
+ vfsDataListStart=wholeFileContent.length # 按照现在的序列化情况,计算出来的起始位置。
167
+ end
87
168
 
88
- # 写入文件:
89
- writeFile(wholeFileContent, victoriaFresh) # 写入文件内容
169
+ # 写入文件:
170
+ writeFile(wholeFileContent, victoriaFresh) # 写入文件内容
90
171
 
91
- appendVfsDataList victoriaFresh # 追加压缩块列表数据。
172
+ appendVfsDataList victoriaFresh # 追加压缩块列表数据。
173
+
174
+ if fileExists # 存在文件,则表明将要发生增量压缩
175
+ writeStamp (rootPath) # 更新时间戳文件
176
+ end # if fileExists # 存在文件,则表明用户要求增量压缩
177
+
92
178
  end # def exz(rootPath)
93
179
 
94
180
  # 写入压缩块文件
95
181
  def writeCompressBlock(compressed, processCounter)
96
- extremeZipOutputFile = File.new("comressed.#{processCounter}.cex", 'wb') # 创建文件
97
- extremeZipOutputFile.syswrite(compressed) # 写入文件
98
- extremeZipOutputFile.close # 关闭文件
182
+ extremeZipOutputFile = File.new("comressed.#{processCounter}.cex", 'wb') # 创建文件
183
+ extremeZipOutputFile.syswrite(compressed) # 写入文件
184
+ extremeZipOutputFile.close # 关闭文件
99
185
  end
100
186
 
101
187
  # 追加压缩块列表数据。
102
188
  def appendVfsDataList (victoriaFresh)
103
- extremeZipOutputFile = File.new("#{victoriaFresh['name']}.exz", 'ab') # 打开文件
189
+ extremeZipOutputFile = File.new("#{victoriaFresh['name']}.exz", 'ab') # 打开文件
104
190
 
105
- processCounter=0 # 块计数器。
191
+ processCounter=0 # 块计数器。
106
192
 
107
- @wholeCbor['vfsDataList'].each do
193
+ @wholeCbor['vfsDataList'].each do
108
194
  #extremeZipOutputFile = File.new("comressed.#{processCounter}.cex", 'wb') # 创建文件
109
195
 
110
196
  currentBlockFile = File.new("comressed.#{processCounter}.cex", 'rb') # 打开文件
@@ -112,17 +198,18 @@ class ExtremeZip
112
198
  wholeFileContent = currentBlockFile.read # 读取全部内容
113
199
 
114
200
  currentBlockFile.close # 关闭文件
201
+ File.delete(currentBlockFile) # 删除数据块文件
115
202
 
116
203
  #wholeFileContent=File.read("comressed.#{processCounter}.cex", 'rb') # 读取压缩块。
117
204
 
118
- puts "wirte file contetn length: #{wholeFileContent.length}" # Debghu
205
+ puts "wirte file contetn length: #{wholeFileContent.length}" # Debghu
119
206
 
120
- extremeZipOutputFile.syswrite(wholeFileContent) # 写入文件
207
+ extremeZipOutputFile.syswrite(wholeFileContent) # 写入文件
121
208
 
122
- processCounter += 1 # 计数
123
- end
209
+ processCounter += 1 # 计数
210
+ end
124
211
 
125
- extremeZipOutputFile.close # 关闭文件
212
+ extremeZipOutputFile.close # 关闭文件
126
213
  end
127
214
 
128
215
  # 写入文件内容
@@ -168,7 +255,7 @@ class ExtremeZip
168
255
 
169
256
  currentBlockFile.close # 关闭文件
170
257
 
171
- #File.delete(currentBlockFile) # 删除数据块文件
258
+ File.delete(currentBlockFile) # 删除数据块文件
172
259
 
173
260
  currentBlockData
174
261
  end
@@ -177,11 +264,8 @@ class ExtremeZip
177
264
  def schedule1Block(filePartCounter)
178
265
  currentBlockData = readBlockFile(filePartCounter) # 读取块文件内容
179
266
 
180
- # currentTaskPipe = Cod.pipe # 任务分配管道
181
267
  currentResponsePipe = Cod.pipe # 任务回复管道
182
268
 
183
- puts("forking sub process, file part counter: #{filePartCounter}") # Debug.
184
-
185
269
  p1 = fork do # 复制出子进程
186
270
  compressInSubProcess(currentBlockData, currentResponsePipe) # 在子进程中具体执行的压缩代码
187
271
  end # p1 = fork do #复制出子进程
@@ -202,11 +286,8 @@ class ExtremeZip
202
286
 
203
287
  # 启动子进程。
204
288
  def launchSubProcesses
205
-
206
- #while ((@filePartCounter < @filePartAmount) && (true)) # 未处理完毕,并且未达到最大子进程个数
207
289
  while ((@filePartCounter < @filePartAmount) && (@filePartCounter<@maxSubProcessAmount)) # 未处理完毕,并且未达到最大子进程个数
208
290
  currentResponsePipe, p1 = schedule1Block(@filePartCounter) # 计划一个块的压缩计算
209
-
210
291
  end # while processDataLength < victoriaFreshData.byte_size do #未处理完毕
211
292
 
212
293
  [@processIdList, @responsePipeList]
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.2.5
4
+ version: 2022.2.21
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-02-04 00:00:00.000000000 Z
11
+ date: 2022-02-19 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.27
89
+ version: 2022.2.20
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: 2022.1.27
92
+ version: 2022.2.20
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.27
99
+ version: 2022.2.20
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: 2022.1.27
102
+ version: 2022.2.20
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: hx_cbor
105
105
  requirement: !ruby/object:Gem::Requirement