VictoriaFreSh 2024.9.15 → 2024.9.17

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/victoriafresh.rb +69 -49
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4fe7e93411178604fe5d047b7bf70b7e0d69c42a4333370a992bbf8197d2d37
4
- data.tar.gz: 5c49124a663f2c8c3f551d37acdb809485f8040de442f7230ab17821fd482fb0
3
+ metadata.gz: 6e0b92b20d099ee3450a94adaae6d3ae6cbba886548bb902bc02f9d2fe7d85a0
4
+ data.tar.gz: 06e05bd4399e4d9f5bee76458e1debed3f94509654d8d386613ada9f88d4c7ae
5
5
  SHA512:
6
- metadata.gz: 70fae2a882fc632395a8c40e5db329288fd6ec18765c4512dabffad48b1f7f79284783136c08ab1dbc1be826f4bbe14018627f37736131eb1d9ead3dc90d232b
7
- data.tar.gz: 75edb2e387d0d2a459d724124f609935dc28352d12c029608c6f85a1855b43cf2cefb85c4092e90a9d10876485d72acea7363e86a0d03328047be7e34aed1662
6
+ metadata.gz: d3fd6678851937db82070f655b63ac3e95a930bf23ae652006c7d9054cea99a4d1dbe1cbb633acec40cd629ad2e1eb4ccaf8a82c302c399f322bff73d8995d1d
7
+ data.tar.gz: 418f0848f48210c0ca5fc325b7721e9a8b238dd3e7c390552a678056137739a5108ba29094b3dd0c3d6e78f4f436dff6f8127ada84950147f889ea838acb4b70
data/lib/victoriafresh.rb CHANGED
@@ -336,7 +336,7 @@ class VictoriaFresh
336
336
  end #if (bufferLength>=@diskFlushSize) #缓冲区总长度已经超过需要的文件长度
337
337
 
338
338
  if (isFinalPart) #是最后一部分
339
- @contentString = @contentPartArray.join #重组成整个字符串
339
+ @contentString = @contentPartArray.join #重组成整个字符串
340
340
 
341
341
  @contentPartArray.clear #清空字符串数组
342
342
  @bufferLength=0 #缓冲区长度归零
@@ -345,19 +345,35 @@ class VictoriaFresh
345
345
 
346
346
  @contentString="" #字符串清空
347
347
 
348
- if (@diskMultiFile) #多个磁盘文件
349
- @diskWriteFileObject=File.new(@diskFileName+@currentDiskFlushSuffix.to_s+'.v', 'wb') #打开文件
350
-
351
- @currentDiskFlushSuffix=@currentDiskFlushSuffix+1 #增加计数
352
-
353
- @diskWriteFileObject.syswrite(contentToWrite) #写入内容
354
-
355
- @diskWriteFileObject.close
356
- else #单个磁盘文件
357
- @diskWriteFileObject.syswrite(contentToWrite) #写入内容
358
-
359
- @diskWriteFileObject.close #关闭文件
360
- end #if (@diskMultiFile) #多个磁盘文件
348
+ if (@diskMultiFile) #多个磁盘文件
349
+ begin
350
+ # 打开文件
351
+ @diskWriteFileObject = File.new("#{@diskFileName}#{@currentDiskFlushSuffix}.v", 'wb')
352
+
353
+ # 增加计数
354
+ @currentDiskFlushSuffix += 1
355
+
356
+ # 写入内容
357
+ @diskWriteFileObject.syswrite(contentToWrite)
358
+
359
+ # 关闭文件
360
+ @diskWriteFileObject.close
361
+ rescue Errno::EACCES => e
362
+ # 处理权限不足的情况
363
+ puts "Error: Unable to create or write to the file #{@diskFileName}#{@currentDiskFlushSuffix}.v - Permission denied."
364
+ puts e.message
365
+ raise # 重新引发异常
366
+ rescue StandardError => e
367
+ # 处理其他标准错误
368
+ puts "Error: An error occurred while creating or writing to the file #{@diskFileName}#{@currentDiskFlushSuffix}.v."
369
+ puts e.message
370
+ raise # 重新引发异常
371
+ end
372
+ else #单个磁盘文件
373
+ @diskWriteFileObject.syswrite(contentToWrite) #写入内容
374
+
375
+ @diskWriteFileObject.close #关闭文件
376
+ end #if (@diskMultiFile) #多个磁盘文件
361
377
  end #if (isFinalPart) #是最后一部分
362
378
  end #if (@diskFlush) #要做磁盘写入
363
379
  end #contentString= assessDiskFlush(contentString) #考虑是否要向磁盘先输出内容
@@ -499,45 +515,49 @@ class VictoriaFresh
499
515
 
500
516
  ignoreFileList=readIgnoreFileList(directoryPathName) # 读取要忽略的文件名列表。
501
517
 
502
- directoryPathName.each_child do |subFile| #一个个文件地处理。
503
- begin
504
- subFilebaseName=subFile.basename.to_s #基本文件名。
505
-
506
- if (ignoreFileList.include?(subFilebaseName)) # 是要忽略的文件
507
- puts "ignore #{subFile}" # 报告,忽略。
508
- elsif (timestampTooEarly(subFile)) # 文件时间过早。
509
- puts "ignore #{subFile} early file" # 报告,忽略。
510
- else # 不忽略
511
- realPath=subFile.expand_path #获取绝对路径。
512
-
513
- packagedSubFile,subFileContent=checkOnce(realPath,subFileStartIndex, layer+1) #打包这个子文件。
514
-
515
- packagedFile['sub_files'] << packagedSubFile #加入到子文件列表中。
516
-
517
- assessDiskFlush(layer) #考虑是否要向磁盘先输出内容
518
-
519
- subFileStartIndex+=packagedSubFile['file_length'] #记录打包的子文件的长度,更新下一个要打包的子文件的起始位置。
518
+ begin # try to list files and directories.
519
+ directoryPathName.each_child do |subFile| #一个个文件地处理。
520
+ begin
521
+ subFilebaseName=subFile.basename.to_s #基本文件名。
520
522
 
521
- packagedFile['file_length']+=packagedSubFile['file_length'] #随着子文件的打包而更新本目录的总长度。
523
+ if (ignoreFileList.include?(subFilebaseName)) # 是要忽略的文件
524
+ puts "ignore #{subFile}" # 报告,忽略。
525
+ elsif (timestampTooEarly(subFile)) # 文件时间过早。
526
+ puts "ignore #{subFile} early file" # 报告,忽略。
527
+ else # 不忽略
528
+ realPath=subFile.expand_path #获取绝对路径。
529
+
530
+ packagedSubFile,subFileContent=checkOnce(realPath,subFileStartIndex, layer+1) #打包这个子文件。
531
+
532
+ packagedFile['sub_files'] << packagedSubFile #加入到子文件列表中。
533
+
534
+ assessDiskFlush(layer) #考虑是否要向磁盘先输出内容
535
+
536
+ subFileStartIndex+=packagedSubFile['file_length'] #记录打包的子文件的长度,更新下一个要打包的子文件的起始位置。
537
+
538
+ packagedFile['file_length']+=packagedSubFile['file_length'] #随着子文件的打包而更新本目录的总长度。
539
+ end
540
+ rescue Errno::EMFILE # too many open Files in process
541
+ puts "Rescued by Errno::EMFILE statement. #{subFile}" #报告错误
522
542
  end
523
- rescue Errno::EMFILE # too many open Files in process
524
- puts "Rescued by Errno::EMFILE statement. #{subFile}" #报告错误
525
- end
526
- end #directoryPathName.each_child do |subFile| #一个个文件地处理。
543
+ end #directoryPathName.each_child do |subFile| #一个个文件地处理。
544
+ rescue Errno::EACCES => e
545
+ # 处理权限不足的情况
546
+ puts e.message
547
+ end # begin # try to list files and directories.
527
548
  end #if (isFile) #是文件,不用再列出其子文件了。
528
549
 
529
- contentToResult="" #要返回的内容
530
-
531
- if (layer==0) #是最外层
532
- assessDiskFlush(layer, true) #考虑是否要向磁盘先输出内容
533
-
534
- if (@diskFlush) #要向磁盘写入缓存内容
535
- else #不向磁盘写入缓存内容
536
- contentToResult=@contentPartArray.join #重新合并成字符串
537
-
538
- end #if (@diskFlush) #要向磁盘写入缓存内容
539
- end #if (layer==0) #是最外层
540
- return packagedFile, contentToResult #返回打包之后的对象。和文件内容字节数组。
550
+ contentToResult="" #要返回的内容
551
+
552
+ if (layer==0) #是最外层
553
+ assessDiskFlush(layer, true) #考虑是否要向磁盘先输出内容
554
+
555
+ if (@diskFlush) #要向磁盘写入缓存内容
556
+ else #不向磁盘写入缓存内容
557
+ contentToResult=@contentPartArray.join #重新合并成字符串
558
+ end #if (@diskFlush) #要向磁盘写入缓存内容
559
+ end #if (layer==0) #是最外层
560
+ return packagedFile, contentToResult #返回打包之后的对象。和文件内容字节数组。
541
561
  end #def downloadOne #下载一个视频。
542
562
  end
543
563
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: VictoriaFreSh
3
3
  version: !ruby/object:Gem::Version
4
- version: 2024.9.15
4
+ version: 2024.9.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hxcan Cai