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