VictoriaFreSh 2022.1.11 → 2022.1.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/victoriafresh.rb +37 -19
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e816682e96950693c25509f5bacef3c369750c4744509b6b4249d07dc3ffb44a
4
- data.tar.gz: c6916510d824a4524375dcd88f92aaa24c259a0d8723ea9631352f8f108ef71a
3
+ metadata.gz: a021bf4ba7e3c19fe3d303849da3fdbd5410f8188af87059e1ca404d77450bf8
4
+ data.tar.gz: 986f3fea84eb15ce0574edbfd6bb9247d00b9002e98080228d5b2c6a79283e53
5
5
  SHA512:
6
- metadata.gz: e98134456774cefe3c9f2a22837d3c810365524807218703646643d8c877d2d5d0d5a46f1660a1ef0117746f93dd9f96e879d135dd3aeef9e47072203c3f5967
7
- data.tar.gz: 8fd84643f71e5c5a1b016ce444131c324be949d1824d4cf14090b51364fc14d8c3fa8555ffbec96c8983f5565b8f81db9669cd64e0eb1a539eaa82ec8a73f276
6
+ metadata.gz: d27b6fead18004368e8948f4e440b213874fe8edcf67b49a86f0ae7046c939125a035db420c865af3c5014f11fa3fb0df262ebc774199edbc043535f41fdfa0e
7
+ data.tar.gz: 7af520afdca24160b014aaeb3995f05418f09319df854d969f48b8e5c4319756336e1b4a886681d844a51d596dc1f2e49afdd419510a1af92eb3ae8aa10eba7a
data/lib/victoriafresh.rb CHANGED
@@ -11,6 +11,7 @@ require 'digest'
11
11
  class VictoriaFresh
12
12
  attr_accessor :diskFlushSize #累积了这么多的数据就向磁盘写入,以减少内存占用
13
13
  attr_accessor :diskFileName #向磁盘写入数据时的文件名或前缀
14
+ attr_accessor :ignoreFileName # 用于指定忽略文件名列表的配置文件的名字
14
15
  attr_accessor :diskMultiFile #向磁盘写入时,是否要写多个文件
15
16
  attr_accessor :diskFlush #要提前磁盘写入文件,以节省内存吗?
16
17
  attr_accessor :currentDiskFlushSuffix #当前的文件后缀。也等价于已经写入的文件片段个数
@@ -19,6 +20,7 @@ class VictoriaFresh
19
20
  @diskFlush=false #要向磁盘写入文件
20
21
  @diskFlushSize=143212 #磁盘分块大小
21
22
  @diskFileName='victoriafreshdata.v' #磁盘文件名
23
+ @ignoreFileName=nil # 忽略文件名列表配置文件名
22
24
  @diskMultiFile=false #磁盘整个文件,不是多个文件
23
25
  @diskWriteFileObject={} #向磁盘写入文件的对象
24
26
  @contentString="" #内容字符串
@@ -88,13 +90,6 @@ class VictoriaFresh
88
90
  victoriaFreshData=@externalDataFile.read(packagedFile['file_length']) #读取内容
89
91
  end # if is_duplicate # 是重复文件。
90
92
 
91
- if (packagedFile['name']=='hgrc')
92
- puts packagedFile # Debug
93
- puts victoriaFreshData # Debug
94
- end
95
-
96
-
97
-
98
93
  pathToMake=pathPrefix + '/' + packagedFile['name'] #构造文件名
99
94
 
100
95
  @fileIdPathMap[fileId]=pathToMake # 记录文件编号与路径之间的映射。
@@ -360,6 +355,31 @@ class VictoriaFresh
360
355
  end #if (@diskFlush) #要做磁盘写入
361
356
  end #contentString= assessDiskFlush(contentString) #考虑是否要向磁盘先输出内容
362
357
 
358
+ # 读取要忽略的文件名列表。
359
+ def readIgnoreFileList (directoryPathName)
360
+ current_paragraph=[] # 列表
361
+ #陈欣
362
+ datastore= "#{directoryPathName.expand_path}/#{@ignoreFileName}" # 配置文件路径
363
+ puts "reading ignore file: #{datastore}" # Debug
364
+
365
+ begin
366
+ File.foreach(datastore).with_index do |line, _line_num|
367
+ puts line.to_s # Debug
368
+ puts "#{line.empty?} #{line.length} #{line.strip.empty?}" # Debug
369
+
370
+ if line.strip.empty? # 空行
371
+ else # 不是空行
372
+ current_paragraph << line.strip # 记录一行
373
+ end # if line.strip.empty? # 空行
374
+ end # File&.foreach(datastore).with_index do |line, _line_num|
375
+
376
+ rescue Errno::ENOENT
377
+ end
378
+
379
+ puts "ignore list: #{current_paragraph}" # Debug
380
+ current_paragraph
381
+ end
382
+
363
383
  def checkOnce(directoryPath, startIndex=0, layer=0) #打包一个目录树。
364
384
  if (@diskFlush) #要向磁盘写入文件
365
385
  if (layer==0) #最外层
@@ -422,18 +442,6 @@ class VictoriaFresh
422
442
  packagedFile['same_file_id']=sameFileId # 设置相同文件的编号。
423
443
  end # if sameFileId.nil? # 不存在相同的文件
424
444
 
425
- if (packagedFile['name']=='hgrc')
426
- puts packagedFile # Debug
427
- puts currentFileContent
428
- puts @contentPartArray.last
429
- puts @contentPartArray.join.length
430
- end # if (packagedFile['name']=='hgrc')
431
-
432
- if ((@contentPartArray.join.length-packagedFile['file_length'])!=(packagedFile['file_start_index']))
433
- puts packagedFile
434
- #raise StandardError
435
- end
436
-
437
445
  assessDiskFlush(layer) #考虑是否要向磁盘先输出内容
438
446
  elsif (isSymLink) #是符号链接
439
447
  linkTarget=directoryPathName.readlink #获取链接目标
@@ -452,9 +460,16 @@ class VictoriaFresh
452
460
 
453
461
  packagedFile['file_length']=0 #本目录的内容长度。
454
462
  packagedFile['sub_files'] = [] #加入到子文件列表中。
463
+
464
+ ignoreFileList=readIgnoreFileList(directoryPathName) # 读取要忽略的文件名列表。
455
465
 
456
466
  directoryPathName.each_child do |subFile| #一个个文件地处理。
457
467
  begin
468
+ subFilebaseName=subFile.basename.to_s #基本文件名。
469
+
470
+ if (ignoreFileList.include?(subFilebaseName)) # 是要忽略的文件
471
+ puts "ignore #{subFile}" # 报告,忽略。
472
+ else # 不忽略
458
473
  realPath=subFile.expand_path #获取绝对路径。
459
474
 
460
475
  packagedSubFile,subFileContent=checkOnce(realPath,subFileStartIndex, layer+1) #打包这个子文件。
@@ -468,6 +483,9 @@ class VictoriaFresh
468
483
  # puts("237, content string length: #{contentString.length}") #Debug
469
484
 
470
485
  packagedFile['file_length']+=packagedSubFile['file_length'] #随着子文件的打包而更新本目录的总长度。
486
+
487
+ end
488
+
471
489
  rescue Errno::EMFILE # File not exist
472
490
  puts "Rescued by Errno::EMFILE statement. #{subFile}" #报告错误
473
491
  end
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: 2022.1.11
4
+ version: 2022.1.15
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-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hx_cbor