VictoriaFreSh 2021.4.17 → 2021.4.18
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 +4 -4
- data/lib/victoriafresh.rb +187 -171
- data/victoriafresh.example.rb +7 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82c0c58d9b1daeffc9217b052959a5b67bf8547a2c51e58cb1fcfa4632fa1839
|
4
|
+
data.tar.gz: 341d862e0b92956637f54c8bd482e93e6ac0ad907a07c6532605008a4a5dc66a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dbc4bc708a277f8d2d4b5277aecd1ba9c5ecd5f3075dcf2d7ac68849bd526e0ef821e747b140fd82aa3f1b6f61860a30dc737dc57b75470eea635a49d412f41
|
7
|
+
data.tar.gz: 33db88a60ea8c9fd03562089312df3e6ddda6bfc41517d29177586a541278871e58075b4b9af057838935f8f089c3727373a682afc79a449a53de5b4377f34d8
|
data/lib/victoriafresh.rb
CHANGED
@@ -21,20 +21,22 @@ class VictoriaFresh
|
|
21
21
|
@diskWriteFileObject={} #向磁盘写入文件的对象
|
22
22
|
@contentString="" #内容字符串
|
23
23
|
@contentPartArray=[] #内容片段数组
|
24
|
+
@currentDiskFlushSuffix=0 #当前的磁盘文件后缀
|
25
|
+
@bufferLength=0 #缓冲区总长度
|
24
26
|
end
|
25
27
|
|
26
28
|
def checkMemoryUsage(lineNumber)
|
27
|
-
|
28
|
-
|
29
|
+
mem= GetProcessMem.new
|
30
|
+
|
29
31
|
puts("#{lineNumber} , Memory: #{mem.mb}"); #Debug
|
30
|
-
|
32
|
+
|
31
33
|
end #def checkMemoryUsage
|
32
|
-
|
34
|
+
|
33
35
|
|
34
36
|
def releaseFiles(victoriaFreshPackagedFileString, contentString) #释放目录树
|
35
|
-
# packagedFile=Com::Stupidbeauty::Victoriafresh::FileMessage.decode(victoriaFreshPackagedFileString) #解码文件消息对象。
|
37
|
+
# packagedFile=Com::Stupidbeauty::Victoriafresh::FileMessage.decode(victoriaFreshPackagedFileString) #解码文件消息对象。
|
36
38
|
packagedFile=CBOR.decode(victoriaFreshPackagedFileString) #解码
|
37
|
-
|
39
|
+
|
38
40
|
|
39
41
|
puts packagedFile #Debug
|
40
42
|
|
@@ -63,7 +65,7 @@ class VictoriaFresh
|
|
63
65
|
elsif #带权限字段
|
64
66
|
File.chmod(permissionNumber, pathToMake) #设置权限
|
65
67
|
end #if (permissionNumber.nil?) #不带权限字段
|
66
|
-
|
68
|
+
|
67
69
|
end #writeFile(pathPrefix, packagedFile, contentString) #写入文件
|
68
70
|
|
69
71
|
#创建符号链接
|
@@ -73,12 +75,12 @@ class VictoriaFresh
|
|
73
75
|
|
74
76
|
pathToMake=pathPrefix + '/' + packagedFile['name'] #构造文件名
|
75
77
|
|
76
|
-
# victoriaFreshDataFile=File.new(pathToMake , "wb") #数据文件。
|
77
|
-
# victoriaFreshDataFile.syswrite(victoriaFreshData) #写入文件。
|
78
|
-
# victoriaFreshDataFile.close #关闭文件。
|
79
|
-
#
|
80
|
-
# FileUtils.touch pathToMake, :mtime => timeObject #设置修改时间
|
81
|
-
|
78
|
+
# victoriaFreshDataFile=File.new(pathToMake , "wb") #数据文件。
|
79
|
+
# victoriaFreshDataFile.syswrite(victoriaFreshData) #写入文件。
|
80
|
+
# victoriaFreshDataFile.close #关闭文件。
|
81
|
+
#
|
82
|
+
# FileUtils.touch pathToMake, :mtime => timeObject #设置修改时间
|
83
|
+
|
82
84
|
puts("data: #{victoriaFreshData}, path: #{pathToMake}") #Debug
|
83
85
|
|
84
86
|
FileUtils.symlink(victoriaFreshData, pathToMake, force: true) #创建符号链接
|
@@ -87,7 +89,7 @@ class VictoriaFresh
|
|
87
89
|
|
88
90
|
if (permissionNumber.nil?) #不带权限字段
|
89
91
|
elsif #带权限字段
|
90
|
-
# File.chmod(permissionNumber, pathToMake) #设置权限
|
92
|
+
# File.chmod(permissionNumber, pathToMake) #设置权限
|
91
93
|
begin #尝试修改链接本身的权限
|
92
94
|
File.lchmod(permissionNumber, pathToMake) #设置权限
|
93
95
|
rescue NotImplementedError #未实现
|
@@ -97,31 +99,31 @@ class VictoriaFresh
|
|
97
99
|
end #def makeSymlink(pathPrefix, packagedFile, contentString) #创建符号链接
|
98
100
|
|
99
101
|
def getTimeObject(packagedFile) #构造时间戳对象
|
100
|
-
# seconds=packagedFile.timestamp.seconds #获取秒数
|
102
|
+
# seconds=packagedFile.timestamp.seconds #获取秒数
|
101
103
|
seconds=packagedFile['timestamp']['seconds'] #获取秒数
|
102
|
-
|
103
|
-
# microSeconds=packagedFile.timestamp.nanos/ 1000.0 #获取毫秒数
|
104
|
+
|
105
|
+
# microSeconds=packagedFile.timestamp.nanos/ 1000.0 #获取毫秒数
|
104
106
|
microSeconds=packagedFile['timestamp']['nanos'] / 1000.0 #获取毫秒数
|
105
107
|
|
106
108
|
timeObject=Time.at(seconds, microSeconds) #构造时间对象
|
107
|
-
|
109
|
+
|
108
110
|
end #getTimeObject(packagedFile) #构造时间戳对象
|
109
111
|
|
110
112
|
def makeDirectory(pathPrefix, packagedFile) #创建目录
|
111
113
|
timeObject=getTimeObject(packagedFile) #构造时间戳对象
|
112
|
-
|
113
114
|
|
114
|
-
|
115
|
+
|
116
|
+
# puts 'mkdir' #Debug
|
115
117
|
pathToMake=File.join(pathPrefix, packagedFile['name'])
|
116
118
|
|
117
|
-
# puts pathToMake #Debug.
|
119
|
+
# puts pathToMake #Debug.
|
118
120
|
|
119
121
|
if (Dir.exist?(pathToMake)) #目录已经存在
|
120
122
|
else #目录 不存在
|
121
123
|
Dir.mkdir(pathToMake) #=> 0
|
122
124
|
end #if (Dir.exist?(pathToMake)) #目录已经存在
|
123
125
|
|
124
|
-
|
126
|
+
|
125
127
|
FileUtils.touch pathToMake, :mtime => timeObject #设置修改时间
|
126
128
|
|
127
129
|
permissionNumber=packagedFile['permission'] #获取权限数字
|
@@ -151,173 +153,187 @@ class VictoriaFresh
|
|
151
153
|
end #if packagedFile.is_file #是文件,则直接写入文件
|
152
154
|
end #def releaseFile(packagedFile, contentString) #释放一个文件
|
153
155
|
|
154
|
-
|
156
|
+
#考虑是否要向磁盘先输出内容
|
155
157
|
def assessDiskFlush(layer, isFinalPart=false)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
while (@contentString.length >= @diskFlushSize) #还有内容要写入
|
160
|
-
contentToWrite=@contentString[0, @diskFlushSize] #取出开头的一段
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
@contentString=@contentString[@diskFlushSize, @contentString.length-@diskFlushSize] #留下剩余的部分
|
165
|
-
|
166
|
-
if (@diskFlush) #要向磁盘写入内容
|
167
|
-
|
168
|
-
@diskWriteFileObject.syswrite(contentToWrite) #写入内容
|
169
|
-
|
170
|
-
@diskWriteFileObject.flush #写入磁盘
|
158
|
+
if (@diskFlush) #要做磁盘写入
|
159
|
+
if (@bufferLength>=@diskFlushSize) #缓冲区总长度已经超过需要的文件长度
|
160
|
+
@contentString = @contentPartArray.join #重组成整个字符串
|
171
161
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
162
|
+
@contentPartArray.clear #清空数组
|
163
|
+
|
164
|
+
while (@contentString.length >= @diskFlushSize) #还有内容要写入
|
165
|
+
contentToWrite=@contentString[0, @diskFlushSize] #取出开头的一段
|
166
|
+
|
167
|
+
@contentString=@contentString[@diskFlushSize, @contentString.length-@diskFlushSize] #留下剩余的部分
|
168
|
+
|
169
|
+
if (@diskMultiFile) #多个磁盘文件
|
170
|
+
@diskWriteFileObject=File.new(@diskFileName+@currentDiskFlushSuffix.to_s, 'wb') #打开文件
|
171
|
+
|
172
|
+
@currentDiskFlushSuffix=@currentDiskFlushSuffix+1 #增加计数
|
173
|
+
|
174
|
+
@diskWriteFileObject.syswrite(contentToWrite) #写入内容
|
175
|
+
|
176
|
+
@diskWriteFileObject.close
|
177
|
+
else #单个磁盘文件
|
178
|
+
|
179
|
+
@diskWriteFileObject.syswrite(contentToWrite) #写入内容
|
180
|
+
|
181
|
+
@diskWriteFileObject.flush #写入磁盘
|
182
|
+
end #@currentDiskFlushSuffix
|
183
|
+
end #while (contentString.length >= @diskFlushSize) #还有内容要写入
|
184
|
+
|
185
|
+
@contentPartArray << @contentString #剩余部分重新加入数组中
|
186
|
+
@bufferLength=@contentString.length #重新记录缓冲区总长度
|
187
|
+
end #if (bufferLength>=@diskFlushSize) #缓冲区总长度已经超过需要的文件长度
|
184
188
|
|
185
|
-
if (
|
189
|
+
if (isFinalPart) #是最后一部分
|
190
|
+
@contentString = @contentPartArray.join #重组成整个字符串
|
191
|
+
|
192
|
+
@contentPartArray.clear #清空字符串数组
|
193
|
+
@bufferLength=0 #缓冲区长度归零
|
186
194
|
|
187
|
-
|
195
|
+
contentToWrite=@contentString #要写入的内容
|
188
196
|
|
189
|
-
@
|
190
|
-
else #不向磁盘写入内容
|
191
|
-
@contentPartArray << contentToWrite #记录到数组中
|
192
|
-
|
197
|
+
@contentString="" #字符串清空
|
193
198
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
199
|
+
if (@diskMultiFile) #多个磁盘文件
|
200
|
+
@diskWriteFileObject=File.new(@diskFileName+@currentDiskFlushSuffix.to_s, 'wb') #打开文件
|
201
|
+
|
202
|
+
@currentDiskFlushSuffix=@currentDiskFlushSuffix+1 #增加计数
|
203
|
+
|
204
|
+
@diskWriteFileObject.syswrite(contentToWrite) #写入内容
|
205
|
+
|
206
|
+
@diskWriteFileObject.close
|
207
|
+
|
208
|
+
|
209
|
+
else #单个磁盘文件
|
210
|
+
@diskWriteFileObject.syswrite(contentToWrite) #写入内容
|
211
|
+
|
212
|
+
@diskWriteFileObject.close #关闭文件
|
213
|
+
|
214
|
+
end #if (@diskMultiFile) #多个磁盘文件
|
215
|
+
end #if (isFinalPart) #是最后一部分
|
216
|
+
end #if (@diskFlush) #要做磁盘写入
|
202
217
|
end #contentString= assessDiskFlush(contentString) #考虑是否要向磁盘先输出内容
|
203
218
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
end #if (
|
212
|
-
end #if (
|
213
|
-
|
214
|
-
end #if (@diskFlush) #要向磁盘写入文件s
|
215
|
-
|
216
|
-
packagedFile={} #创建文件消息对象。
|
217
|
-
|
218
|
-
packagedFile['sub_files'] = [] #加入到子文件列表中。
|
219
|
-
|
220
|
-
directoryPathName=Pathname.new(directoryPath) #构造路径名字对象。
|
221
|
-
|
222
|
-
baseName=directoryPathName.basename.to_s #基本文件名。
|
223
|
-
|
224
|
-
packagedFile['name']=baseName #设置文件名。
|
225
|
-
|
226
|
-
isFile=directoryPathName.file? #是否是文件。
|
227
|
-
isSymLink=directoryPathName.symlink? #是否是符号链接
|
228
|
-
|
229
|
-
packagedFile['is_file']=isFile #设置属性,是否是文件。
|
230
|
-
packagedFile['file_start_index']=startIndex #记录文件内容的开始位置。
|
231
|
-
|
232
|
-
packagedFile['is_symlink']=isSymLink #设置属性,是否是符号链接
|
233
|
-
|
234
|
-
puts directoryPath #Dbug.
|
235
|
-
|
236
|
-
#记录时间戳:
|
237
|
-
begin #读取时间戳
|
238
|
-
mtimeStamp=File.mtime(directoryPath) #获取时间戳
|
239
|
-
|
240
|
-
packagedFile['timestamp']={} #时间戳
|
241
|
-
packagedFile['timestamp']['seconds']=mtimeStamp.tv_sec #设置秒数
|
242
|
-
packagedFile['timestamp']['nanos']=mtimeStamp.tv_nsec #设置纳秒数
|
243
|
-
|
244
|
-
packagedFile['permission']=(File.stat(directoryPath).mode & 07777 ) #设置权限信息
|
245
|
-
rescue Errno::ENOENT
|
246
|
-
rescue Errno::EACCES #权限受限
|
247
|
-
end #begin #读取时间戳
|
248
|
-
|
249
|
-
if (isFile) #是文件,不用再列出其子文件了。
|
250
|
-
packagedFile['file_length']=directoryPathName.size #记录文件的内容长度。
|
251
|
-
|
252
|
-
#读取文件内容:
|
253
|
-
fileToReadContent=File.new(directoryPath,"rb") #创建文件。
|
254
|
-
@contentString= @contentString + fileToReadContent.read #全部读取。
|
255
|
-
|
256
|
-
assessDiskFlush(layer) #考虑是否要向磁盘先输出内容
|
257
|
-
elsif (isSymLink) #是符号链接
|
258
|
-
linkTarget=directoryPathName.readlink #获取链接目标
|
259
|
-
|
260
|
-
# 待续,设置内容长度。符号链接字符串的长度
|
261
|
-
packagedFile['file_length']=linkTarget.to_s.bytesize #记录文件的内容长度。
|
262
|
-
|
263
|
-
#读取文件内容:
|
264
|
-
# fileToReadContent=File.new(directoryPath,"rb") #创建文件。
|
265
|
-
@contentString= @contentString + StringIO.new(linkTarget.to_s).binmode.read #全部读取。
|
266
|
-
|
267
|
-
assessDiskFlush(layer) #考虑是否要向磁盘先输出内容
|
268
|
-
|
269
|
-
else #是目录。
|
270
|
-
# contentString="" #容纳内容的字符串。
|
271
|
-
subFileStartIndex=startIndex #子文件的起始位置,以此目录的起始位置为基准。
|
272
|
-
|
273
|
-
packagedFile['file_length']=0 #本目录的内容长度。
|
274
|
-
|
275
|
-
directoryPathName.each_child do |subFile| #一个个文件地处理。
|
276
|
-
# puts("sub file: #{subFile}, class: #{subFile.class}, symlink: #{subFile.symlink?}, expand_path: #{subFile.expand_path}, file?: #{subFile.file?}") #Debug.
|
277
|
-
# checkMemoryUsage(221)
|
278
|
-
realPath=subFile.expand_path #获取绝对路径。
|
219
|
+
def checkOnce(directoryPath, startIndex=0, layer=0) #打包一个目录树。
|
220
|
+
if (@diskFlush) #要向磁盘写入文件
|
221
|
+
if (layer==0) #最外层
|
222
|
+
if (@diskMultiFile) #要写多个文件
|
223
|
+
else #不写多个文件
|
224
|
+
@diskWriteFileObject=File.new(@diskFileName, 'wb') #打开文件
|
225
|
+
end #if (@diskMultiFile) #要写多个文件
|
226
|
+
end #if (layer==0) #最外层
|
227
|
+
end #if (@diskFlush) #要向磁盘写入文件s
|
279
228
|
|
280
|
-
|
229
|
+
packagedFile={} #创建文件消息对象。
|
281
230
|
|
282
|
-
packagedFile['sub_files']
|
231
|
+
packagedFile['sub_files'] = [] #加入到子文件列表中。
|
283
232
|
|
284
|
-
|
233
|
+
directoryPathName=Pathname.new(directoryPath) #构造路径名字对象。
|
285
234
|
|
286
|
-
|
287
|
-
|
288
|
-
# contentString = contentString + subFileContent #串接文件内容。
|
235
|
+
baseName=directoryPathName.basename.to_s #基本文件名。
|
289
236
|
|
290
|
-
|
291
|
-
|
237
|
+
packagedFile['name']=baseName #设置文件名。
|
292
238
|
|
293
|
-
|
239
|
+
isFile=directoryPathName.file? #是否是文件。
|
240
|
+
isSymLink=directoryPathName.symlink? #是否是符号链接
|
294
241
|
|
295
|
-
|
242
|
+
packagedFile['is_file']=isFile #设置属性,是否是文件。
|
243
|
+
packagedFile['file_start_index']=startIndex #记录文件内容的开始位置。
|
296
244
|
|
297
|
-
packagedFile['
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
245
|
+
packagedFile['is_symlink']=isSymLink #设置属性,是否是符号链接
|
246
|
+
|
247
|
+
puts directoryPath #Dbug.
|
248
|
+
|
249
|
+
#记录时间戳:
|
250
|
+
begin #读取时间戳
|
251
|
+
mtimeStamp=File.mtime(directoryPath) #获取时间戳
|
252
|
+
|
253
|
+
packagedFile['timestamp']={} #时间戳
|
254
|
+
packagedFile['timestamp']['seconds']=mtimeStamp.tv_sec #设置秒数
|
255
|
+
packagedFile['timestamp']['nanos']=mtimeStamp.tv_nsec #设置纳秒数
|
256
|
+
|
257
|
+
packagedFile['permission']=(File.stat(directoryPath).mode & 07777 ) #设置权限信息
|
258
|
+
rescue Errno::ENOENT
|
259
|
+
rescue Errno::EACCES #权限受限
|
260
|
+
end #begin #读取时间戳
|
261
|
+
|
262
|
+
if (isFile) #是文件,不用再列出其子文件了。
|
263
|
+
packagedFile['file_length']=directoryPathName.size #记录文件的内容长度。
|
264
|
+
|
265
|
+
#读取文件内容:
|
266
|
+
fileToReadContent=File.new(directoryPath,"rb") #创建文件。
|
267
|
+
currentFileContent=fileToReadContent.read #全部读取
|
268
|
+
@contentPartArray << currentFileContent
|
269
|
+
@bufferLength=@bufferLength+ currentFileContent.length #记录缓冲区总长度
|
270
|
+
# @contentString= @contentString + fileToReadContent.read #全部读取。
|
271
|
+
|
272
|
+
assessDiskFlush(layer) #考虑是否要向磁盘先输出内容
|
273
|
+
elsif (isSymLink) #是符号链接
|
274
|
+
linkTarget=directoryPathName.readlink #获取链接目标
|
275
|
+
|
276
|
+
# 待续,设置内容长度。符号链接字符串的长度
|
277
|
+
packagedFile['file_length']=linkTarget.to_s.bytesize #记录文件的内容长度。
|
278
|
+
|
279
|
+
#读取文件内容:
|
280
|
+
# fileToReadContent=File.new(directoryPath,"rb") #创建文件。
|
281
|
+
currentFileContent=StringIO.new(linkTarget.to_s).binmode.read #全部读取。
|
282
|
+
@contentPartArray << currentFileContent #加入数组
|
283
|
+
@bufferLength=@bufferLength + currentFileContent.length #记录缓冲区总长度
|
284
|
+
# @contentString= @contentString + StringIO.new(linkTarget.to_s).binmode.read #全部读取。
|
285
|
+
|
286
|
+
assessDiskFlush(layer) #考虑是否要向磁盘先输出内容
|
287
|
+
|
288
|
+
else #是目录。
|
289
|
+
# contentString="" #容纳内容的字符串。
|
290
|
+
subFileStartIndex=startIndex #子文件的起始位置,以此目录的起始位置为基准。
|
291
|
+
|
292
|
+
packagedFile['file_length']=0 #本目录的内容长度。
|
293
|
+
|
294
|
+
directoryPathName.each_child do |subFile| #一个个文件地处理。
|
295
|
+
# puts("sub file: #{subFile}, class: #{subFile.class}, symlink: #{subFile.symlink?}, expand_path: #{subFile.expand_path}, file?: #{subFile.file?}") #Debug.
|
296
|
+
# checkMemoryUsage(221)
|
297
|
+
realPath=subFile.expand_path #获取绝对路径。
|
303
298
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
if (@diskFlush) #要向磁盘写入缓存内容
|
312
|
-
else #不向磁盘写入缓存内容
|
313
|
-
contentToResult=@contentPartArray.join #重新合并成字符串
|
314
|
-
|
315
|
-
end #if (@diskFlush) #要向磁盘写入缓存内容
|
316
|
-
|
317
|
-
end #if (layer==0) #是最外层
|
299
|
+
packagedSubFile,subFileContent=checkOnce(realPath,subFileStartIndex, layer+1) #打包这个子文件。
|
300
|
+
|
301
|
+
packagedFile['sub_files'] << packagedSubFile #加入到子文件列表中。
|
302
|
+
|
303
|
+
# puts("sub file content: #{subFileContent}, nil?: #{subFileContent.nil?}" ) #Debug
|
304
|
+
|
305
|
+
# puts(" content: #{contentString}, nil?: #{contentString.nil? }") #Debug
|
318
306
|
|
307
|
+
# contentString = contentString + subFileContent #串接文件内容。
|
308
|
+
|
309
|
+
assessDiskFlush(layer) #考虑是否要向磁盘先输出内容
|
310
|
+
|
311
|
+
|
312
|
+
subFileStartIndex+=packagedSubFile['file_length'] #记录打包的子文件的长度,更新下一个要打包的子文件的起始位置。
|
313
|
+
|
314
|
+
# puts("237, content string length: #{contentString.length}") #Debug
|
315
|
+
|
316
|
+
packagedFile['file_length']+=packagedSubFile['file_length'] #随着子文件的打包而更新本目录的总长度。
|
317
|
+
end #directoryPathName.each_child do |subFile| #一个个文件地处理。
|
318
|
+
end #if (isFile) #是文件,不用再列出其子文件了。
|
319
|
+
|
320
|
+
# puts("300, contentString: #{contentString}, nil?: #{contentString.nil?}, direcotry path: #{directoryPath}, layer: #{layer}") #Debug
|
321
|
+
|
322
|
+
|
323
|
+
# puts("302, contentString: #{contentString}, nil?: #{contentString.nil?}, direcotry path: #{directoryPath}, layer: #{layer}") #Debug
|
324
|
+
|
325
|
+
contentToResult="" #要返回的内容
|
326
|
+
|
327
|
+
if (layer==0) #是最外层
|
328
|
+
assessDiskFlush(layer, true) #考虑是否要向磁盘先输出内容
|
329
|
+
|
330
|
+
if (@diskFlush) #要向磁盘写入缓存内容
|
331
|
+
else #不向磁盘写入缓存内容
|
332
|
+
contentToResult=@contentPartArray.join #重新合并成字符串
|
319
333
|
|
320
|
-
|
321
|
-
|
334
|
+
end #if (@diskFlush) #要向磁盘写入缓存内容
|
335
|
+
end #if (layer==0) #是最外层
|
336
|
+
return packagedFile, contentToResult #返回打包之后的对象。和文件内容字节数组。
|
337
|
+
end #def downloadOne #下载一个视频。
|
322
338
|
end
|
323
339
|
|
data/victoriafresh.example.rb
CHANGED
@@ -9,7 +9,10 @@ else #指定了命令行参数。
|
|
9
9
|
|
10
10
|
$clipDownloader=VictoriaFresh.new #创建下载器。
|
11
11
|
|
12
|
-
$clipDownloader.diskFlush=
|
12
|
+
$clipDownloader.diskFlush=true #向磁盘写入缓存
|
13
|
+
$clipDownloader.diskMultiFile=true #写多个磁盘文件
|
14
|
+
$clipDownloader.diskFileName='victoriafreshdata.v.' #磁盘文件名前缀
|
15
|
+
$clipDownloader.diskFlushSize=32*1024*1024 #磁盘文件大小
|
13
16
|
|
14
17
|
victoriaFresh,victoriaFreshData=$clipDownloader.checkOnce($rootPath) #打包该目录树。
|
15
18
|
|
@@ -24,7 +27,7 @@ else #指定了命令行参数。
|
|
24
27
|
|
25
28
|
victoriaFreshFile.close #关闭文件。
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
# victoriaFreshDataFile=File.new("victoriafreshdata.v","wb") #数据文件。
|
31
|
+
# victoriaFreshDataFile.syswrite(victoriaFreshData) #写入文件。
|
32
|
+
# victoriaFreshDataFile.close #关闭文件。
|
30
33
|
end
|