EXtremeZip 2022.1.27 → 2022.2.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/extremeunzip.zzaqsu.rb +59 -76
- data/lib/extremezip.zzaqsv.rb +150 -20
- metadata +6 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d6f7accde07ae32cb5a0b760673749535b3cbbcaf33df4688ca303b427080bff
         | 
| 4 | 
            +
              data.tar.gz: 808669d1eb5fa58e9f6d89b5e8a01c0bafebf0f49475f215aee8cbb0f2b756e3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 634db332f4d8656a233ab935ab82c83ef1dc934861534da11c47dfbf6e93e98a6432e7542a4951fdb3d9e5b294c1fb397185d471d07e2fb8e026f9922eacd8f2
         | 
| 7 | 
            +
              data.tar.gz: 35eb1b03750c86e87f71fb997f529cd79ef407d42d3ced0d34ecd831fe503bb74acfd37101c4bacc02ee809e49e0285efa5844c2aabb22e19f2c010efe2d52df
         | 
    
        data/lib/extremeunzip.zzaqsu.rb
    CHANGED
    
    | @@ -1,20 +1,47 @@ | |
| 1 1 | 
             
            #!/usr/bin/env ruby
         | 
| 2 2 |  | 
| 3 | 
            -
            # require 'pathname'
         | 
| 4 | 
            -
            # require File.dirname(__FILE__)+'/filemessage.pb.rb'
         | 
| 5 3 | 
             
            require 'victoriafresh'
         | 
| 6 4 | 
             
            require 'cbor'
         | 
| 7 5 | 
             
            require 'lzma'
         | 
| 8 6 | 
             
            require 'get_process_mem'
         | 
| 9 7 |  | 
| 10 8 | 
             
            def checkMemoryUsage(lineNumber)
         | 
| 11 | 
            -
             | 
| 9 | 
            +
              mem = GetProcessMem.new
         | 
| 12 10 |  | 
| 13 | 
            -
             | 
| 11 | 
            +
              puts("#{lineNumber} ,  Memory: #{mem.mb}"); # Debug
         | 
| 14 12 | 
             
            end # def checkMemoryUsage
         | 
| 15 13 |  | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 14 | 
            +
             | 
| 15 | 
            +
             | 
| 16 | 
            +
             | 
| 17 | 
            +
            class ExtremeUnZip
         | 
| 18 | 
            +
              # 根据偏移值来读取压缩块数据列表。
         | 
| 19 | 
            +
            def readVfsDataList(wholeCbor) 
         | 
| 20 | 
            +
                    compressedVfsDataList = [] # 获取压缩后的数据块列表
         | 
| 21 | 
            +
                    startIndix=wholeCbor['vfsDataListStart'] # 初始起始位置。
         | 
| 22 | 
            +
                    
         | 
| 23 | 
            +
                    puts "whole length: #{@wholeFileContent.length}, list conent: #{wholeCbor['vfsDataList']}" # Debug
         | 
| 24 | 
            +
                    
         | 
| 25 | 
            +
                    
         | 
| 26 | 
            +
                    wholeCbor['vfsDataList'].each do |currentBlockInfo| # 一个个块地处理
         | 
| 27 | 
            +
                      length=currentBlockInfo['length'] # 获取长度。
         | 
| 28 | 
            +
                      
         | 
| 29 | 
            +
                      currentBlock=@wholeFileContent[startIndix, length] # 读取内容
         | 
| 30 | 
            +
                      
         | 
| 31 | 
            +
                      puts "start index: #{startIndix}, length: #{length}, content length: #{currentBlock.length}" # Debug
         | 
| 32 | 
            +
                      
         | 
| 33 | 
            +
                      compressedVfsDataList << currentBlock # 加入当前块
         | 
| 34 | 
            +
                      
         | 
| 35 | 
            +
                      startIndix+=length # 位移。
         | 
| 36 | 
            +
                    end
         | 
| 37 | 
            +
              
         | 
| 38 | 
            +
                    compressedVfsDataList # 返回 内容
         | 
| 39 | 
            +
            end
         | 
| 40 | 
            +
              
         | 
| 41 | 
            +
              # 根据版本号,提取VFS数据内容
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              
         | 
| 44 | 
            +
              def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion)
         | 
| 18 45 | 
             
                victoriaFreshData = '' # 解压后的数据块整体
         | 
| 19 46 | 
             
                dataFileName = 'victoriafreshdata.w' # 数据文件名
         | 
| 20 47 | 
             
                dataFile = {} # 数据文件对象
         | 
| @@ -31,6 +58,10 @@ def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) | |
| 31 58 | 
             
                    dataFile.close # 关闭文件
         | 
| 32 59 | 
             
                elsif (fileVersion >= 30) # 30以上版本
         | 
| 33 60 | 
             
                    compressedVfsDataList = wholeCbor['vfsDataList'] # 获取压缩后的数据块列表
         | 
| 61 | 
            +
                    
         | 
| 62 | 
            +
                    if (fileVersion>=251) # 251 以上版本。要按照偏移值来读取压缩数据块列表。
         | 
| 63 | 
            +
                      compressedVfsDataList=readVfsDataList(wholeCbor) # 根据偏移值来读取压缩块数据列表。
         | 
| 64 | 
            +
                    end # if (fileVersion>=251) # 251 以上版本
         | 
| 34 65 |  | 
| 35 66 | 
             
                    puts("data block amont: #{compressedVfsDataList.length}") # Debug
         | 
| 36 67 |  | 
| @@ -44,18 +75,12 @@ def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) | |
| 44 75 |  | 
| 45 76 | 
             
                        begin # 解压
         | 
| 46 77 | 
             
                            currentRawData = LZMA.decompress(currentCompressed) # 解压这一块
         | 
| 47 | 
            -
                            
         | 
| 48 78 |  | 
| 49 79 | 
             
                            dataFile.syswrite(currentRawData) # 写入内容
         | 
| 50 80 | 
             
                        rescue RuntimeError => e # 解压失败
         | 
| 51 81 | 
             
                            puts "Warning: the exz file may be incomplete." # 报告错误。文件可能不完整。
         | 
| 52 82 | 
             
                        end # begin # 解压
         | 
| 53 83 |  | 
| 54 | 
            -
                        #             victoriaFreshData=victoriaFreshData+currentRawData #追加
         | 
| 55 | 
            -
                        #             victoriaFreshData << currentRawData #追加
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                        #puts("byte size: #{victoriaFreshData.bytesize}") # debug.
         | 
| 58 | 
            -
             | 
| 59 84 | 
             
                        dataBlockCounter += 1 # count
         | 
| 60 85 | 
             
                    end # compressedVfsDataList.each do |currentCompressed|
         | 
| 61 86 |  | 
| @@ -65,88 +90,46 @@ def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) | |
| 65 90 | 
             
                dataFileName # 返回解压后的数据块整体
         | 
| 66 91 | 
             
            end # def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) #根据版本号,提取VFS数据内容
         | 
| 67 92 |  | 
| 68 | 
            -
             | 
| 69 | 
            -
                victoriaFreshData = '' # 解压后的数据块整体
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                if (fileVersion == 14) # 14版本
         | 
| 72 | 
            -
                    compressedVfsData = wholeCbor['vfsData'] # 获取压缩后的数据内容
         | 
| 73 | 
            -
             | 
| 74 | 
            -
                    victoriaFreshData = LZMA.decompress(compressedVfsData) # 解压缩数据内容
         | 
| 75 | 
            -
                elsif (fileVersion >= 30) # 30以上版本
         | 
| 76 | 
            -
                    compressedVfsDataList = wholeCbor['vfsDataList'] # 获取压缩后的数据块列表
         | 
| 77 | 
            -
             | 
| 78 | 
            -
                    puts("data block amont: #{compressedVfsDataList.length}") # Debug
         | 
| 79 | 
            -
             | 
| 80 | 
            -
                    dataBlockCounter = 0 # Data block counter
         | 
| 81 | 
            -
             | 
| 82 | 
            -
                    compressedVfsDataList.each do |currentCompressed| # 一块块地解压
         | 
| 83 | 
            -
                        puts("data block counter: #{dataBlockCounter}") # Debug
         | 
| 84 | 
            -
                        checkMemoryUsage(34)
         | 
| 85 | 
            -
             | 
| 86 | 
            -
                        currentRawData = LZMA.decompress(currentCompressed) # 解压这一块
         | 
| 87 | 
            -
             | 
| 88 | 
            -
                        #             victoriaFreshData=victoriaFreshData+currentRawData #追加
         | 
| 89 | 
            -
                        victoriaFreshData << currentRawData # 追加
         | 
| 90 | 
            -
             | 
| 91 | 
            -
                        puts("byte size: #{victoriaFreshData.bytesize}") # debug.
         | 
| 92 | 
            -
             | 
| 93 | 
            -
                        dataBlockCounter += 1 # count
         | 
| 94 | 
            -
                    end # compressedVfsDataList.each do |currentCompressed|
         | 
| 95 | 
            -
                end # if (fileVersion==14) #14版本
         | 
| 96 | 
            -
             | 
| 97 | 
            -
                victoriaFreshData # 返回解压后的数据块整体
         | 
| 98 | 
            -
            end #        extractVfsDataWithVersion(wholeCbor, fileVersion) #根据版本号,提取VFS数据内容
         | 
| 99 | 
            -
             | 
| 100 | 
            -
            class ExtremeUnZip
         | 
| 101 | 
            -
                # 解压
         | 
| 93 | 
            +
              # 解压
         | 
| 102 94 | 
             
                def exuz(rootPath)
         | 
| 103 | 
            -
             | 
| 104 | 
            -
                    
         | 
| 105 | 
            -
                    wholeFileContent = File.read(rootPath) # 最终文件内容
         | 
| 95 | 
            +
                  result = true # 解压结果
         | 
| 106 96 |  | 
| 107 | 
            -
             | 
| 97 | 
            +
                  currentBlockFile = File.new(rootPath, 'rb') # 打开文件
         | 
| 108 98 |  | 
| 109 | 
            -
             | 
| 99 | 
            +
                  @wholeFileContent = currentBlockFile.read # 读取全部内容
         | 
| 110 100 |  | 
| 111 | 
            -
             | 
| 101 | 
            +
                  currentBlockFile.close # 关闭文件
         | 
| 112 102 |  | 
| 113 | 
            -
             | 
| 103 | 
            +
                  checkMemoryUsage(60)
         | 
| 114 104 |  | 
| 115 | 
            -
             | 
| 105 | 
            +
                  wholeCborByteArray = @wholeFileContent[4..-1] # 从第5个到末尾
         | 
| 116 106 |  | 
| 117 107 | 
             
                    begin # 可能出错。
         | 
| 118 | 
            -
             | 
| 108 | 
            +
                      options = {:tolerant => true}
         | 
| 119 109 |  | 
| 120 | 
            -
             | 
| 110 | 
            +
                      wholeCbor = CBOR.decode(wholeCborByteArray, options) # 解码
         | 
| 121 111 |  | 
| 122 | 
            -
             | 
| 112 | 
            +
                      fileVersion = wholeCbor['version'] # 获取版本号
         | 
| 123 113 |  | 
| 124 114 | 
             
                        if (fileVersion < 14) # 版本号过小
         | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 115 | 
            +
                          checkMemoryUsage(85)
         | 
| 116 | 
            +
                          puts 'file version too old' # 报告错误
         | 
| 127 117 | 
             
                        else # 版本号够大
         | 
| 128 | 
            -
             | 
| 118 | 
            +
                          compressedVfsMenu = wholeCbor['vfsMenu'] # 获取压缩后的目录内容
         | 
| 129 119 |  | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 120 | 
            +
                          checkMemoryUsage(90)
         | 
| 121 | 
            +
                          replyByteArray = LZMA.decompress(compressedVfsMenu) # 解码目录VFS字节数组内容
         | 
| 132 122 |  | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 135 | 
            -
             | 
| 136 | 
            -
                            #         victoriaFreshData=extractVfsDataWithVersion(wholeCbor, fileVersion) #根据版本号,提取VFS数据内容
         | 
| 137 | 
            -
                            victoriaFreshDataFile = extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) # 根据版本号,提取VFS数据内容
         | 
| 138 | 
            -
                            
         | 
| 139 | 
            -
                            #         puts victoriaFreshData #Debug
         | 
| 140 | 
            -
                            
         | 
| 141 | 
            -
                            checkMemoryUsage(100)
         | 
| 142 | 
            -
                            $clipDownloader = VictoriaFresh.new # 创建下载器。
         | 
| 143 | 
            -
                            
         | 
| 144 | 
            -
                            $clipDownloader.releaseFilesExternalDataFile(replyByteArray, victoriaFreshDataFile) # 释放各个文件
         | 
| 123 | 
            +
                          checkMemoryUsage(95)
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                          victoriaFreshDataFile = extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) # 根据版本号,提取VFS数据内容
         | 
| 145 126 |  | 
| 146 | 
            -
             | 
| 127 | 
            +
                          checkMemoryUsage(100)
         | 
| 128 | 
            +
                          $clipDownloader = VictoriaFresh.new # 创建下载器。
         | 
| 147 129 |  | 
| 148 | 
            -
             | 
| 130 | 
            +
                          $clipDownloader.releaseFilesExternalDataFile(replyByteArray, victoriaFreshDataFile) # 释放各个文件
         | 
| 149 131 |  | 
| 132 | 
            +
                          fileToRemove = File.new(victoriaFreshDataFile) # 要删除的文件
         | 
| 150 133 | 
             
                        end # if (fileVersion<14) #版本号过小
         | 
| 151 134 |  | 
| 152 135 | 
             
                        result =true # 解压成功
         | 
    
        data/lib/extremezip.zzaqsv.rb
    CHANGED
    
    | @@ -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 |  | 
| @@ -48,34 +50,161 @@ class ExtremeZip | |
| 48 50 |  | 
| 49 51 | 
             
                # 加入基本文件信息
         | 
| 50 52 | 
             
                def addBasicFileInformation
         | 
| 51 | 
            -
                    @wholeCbor['version'] =  | 
| 53 | 
            +
                    @wholeCbor['version'] = 251 # 文件格式版本号
         | 
| 52 54 |  | 
| 53 55 | 
             
                    uuid = UUID.new # 获取生成器
         | 
| 54 56 | 
             
                    @wholeCbor['uuid'] = uuid.generate # 指定本个压缩包的唯一编号
         | 
| 57 | 
            +
                    
         | 
| 58 | 
            +
                    @wholeCbor['website']='https://rubygems.org/gems/EXtremeZip' # 加入网站地址
         | 
| 59 | 
            +
                    
         | 
| 60 | 
            +
                    @wholeCbor['vfsDataListStart']=198910 # 压缩 VFS 数据列表起始位置。
         | 
| 55 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 | 
            +
                      stamp = wholeCbor['timestamp'] # 获取时间戳
         | 
| 111 | 
            +
                    rescue Errno::ENOENT
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                    end
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                    
         | 
| 116 | 
            +
                  end #unless isFile #是文件就跳过。 
         | 
| 117 | 
            +
                  
         | 
| 118 | 
            +
                  return stamp, fileExists # 返回时间戳。
         | 
| 119 | 
            +
                end #loadStamp(rootPath) # 读取时间戳阈值。
         | 
| 56 120 |  | 
| 57 121 | 
             
                # 压缩
         | 
| 58 122 | 
             
                def exz(rootPath)
         | 
| 59 | 
            -
             | 
| 123 | 
            +
                  timestampTHreshold, fileExists=loadStamp(rootPath) # 读取时间戳阈值。
         | 
| 124 | 
            +
                  
         | 
| 125 | 
            +
                  #陈欣
         | 
| 126 | 
            +
                  
         | 
| 127 | 
            +
                  if (timestampTHreshold > 0) # 有效的时间戳
         | 
| 128 | 
            +
                    @clipDownloader.timestampThreshold=timestampTHreshold # 设置文件时间戳阈值。
         | 
| 129 | 
            +
                  end #if (timestampTHreshold > 0) # 有效的时间戳
         | 
| 130 | 
            +
                  
         | 
| 131 | 
            +
                  if fileExists # 存在文件,则表明将要发生增量压缩
         | 
| 132 | 
            +
                    @wholeCbor['incremental']=true # 是增量压缩。
         | 
| 133 | 
            +
                    
         | 
| 134 | 
            +
                  end # if fileExists # 存在文件,则表明用户要求增量压缩
         | 
| 60 135 |  | 
| 61 | 
            -
             | 
| 136 | 
            +
                  @wholeCbor['timestamp']=@processTimestamp # 记录进程启动的时间戳。
         | 
| 137 | 
            +
                  
         | 
| 138 | 
            +
                  victoriaFresh, = @clipDownloader.checkOnce(rootPath) # 打包该目录树。
         | 
| 62 139 |  | 
| 63 | 
            -
             | 
| 140 | 
            +
                  @filePartAmount = @clipDownloader.currentDiskFlushSuffix # 获取文件个数
         | 
| 64 141 |  | 
| 65 | 
            -
             | 
| 142 | 
            +
                  compressVfsMenu(victoriaFresh) # 压缩目录数据。
         | 
| 66 143 |  | 
| 67 | 
            -
             | 
| 144 | 
            +
                  addBasicFileInformation # 加入基本文件信息
         | 
| 68 145 |  | 
| 69 | 
            -
             | 
| 146 | 
            +
                  processIdList, responsePipeList = launchSubProcesses # 启动子进程。
         | 
| 70 147 |  | 
| 71 | 
            -
             | 
| 72 | 
            -
                    @wholeCbor['vfsDataList'] = @vfsDataList # 加入数据
         | 
| 148 | 
            +
                  receiveCompressedVfsDataList(processIdList, responsePipeList) # 接收压缩后的数据块列表
         | 
| 73 149 |  | 
| 150 | 
            +
                  checkMemoryUsage(155)
         | 
| 151 | 
            +
                  @wholeCbor['vfsDataList'] = @vfsDataList # 加入数据
         | 
| 152 | 
            +
             | 
| 153 | 
            +
                  wholeFileContent = 'exz' + "\0" + @wholeCbor.to_cbor # 追加CBOR字节数组
         | 
| 154 | 
            +
                    
         | 
| 155 | 
            +
                  vfsDataListStart=wholeFileContent.length # 按照现在的序列化情况,计算出来的起始位置。
         | 
| 156 | 
            +
                    
         | 
| 157 | 
            +
                  while (vfsDataListStart!=@wholeCbor['vfsDataListStart']) # 计算出的偏移不一致
         | 
| 158 | 
            +
                    @wholeCbor['vfsDataListStart']=vfsDataListStart # 使用新的值
         | 
| 74 159 | 
             
                    wholeFileContent = 'exz' + "\0" + @wholeCbor.to_cbor # 追加CBOR字节数组
         | 
| 160 | 
            +
                    vfsDataListStart=wholeFileContent.length # 按照现在的序列化情况,计算出来的起始位置。          
         | 
| 161 | 
            +
                  end
         | 
| 75 162 |  | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 163 | 
            +
                  # 写入文件:
         | 
| 164 | 
            +
                  writeFile(wholeFileContent, victoriaFresh) # 写入文件内容
         | 
| 165 | 
            +
                    
         | 
| 166 | 
            +
                  appendVfsDataList victoriaFresh # 追加压缩块列表数据。
         | 
| 167 | 
            +
                  
         | 
| 168 | 
            +
                  if fileExists # 存在文件,则表明将要发生增量压缩
         | 
| 169 | 
            +
                    writeStamp # 更新时间戳文件
         | 
| 170 | 
            +
                  end # if fileExists # 存在文件,则表明用户要求增量压缩
         | 
| 171 | 
            +
                  
         | 
| 78 172 | 
             
                end # def exz(rootPath)
         | 
| 173 | 
            +
                
         | 
| 174 | 
            +
                # 写入压缩块文件
         | 
| 175 | 
            +
                def writeCompressBlock(compressed, processCounter) 
         | 
| 176 | 
            +
                  extremeZipOutputFile = File.new("comressed.#{processCounter}.cex", 'wb') # 创建文件
         | 
| 177 | 
            +
                  extremeZipOutputFile.syswrite(compressed) # 写入文件
         | 
| 178 | 
            +
                  extremeZipOutputFile.close # 关闭文件
         | 
| 179 | 
            +
                end
         | 
| 180 | 
            +
                
         | 
| 181 | 
            +
                # 追加压缩块列表数据。
         | 
| 182 | 
            +
                def appendVfsDataList (victoriaFresh)
         | 
| 183 | 
            +
                  extremeZipOutputFile = File.new("#{victoriaFresh['name']}.exz", 'ab') # 打开文件
         | 
| 184 | 
            +
                    
         | 
| 185 | 
            +
                  processCounter=0 # 块计数器。
         | 
| 186 | 
            +
                    
         | 
| 187 | 
            +
                  @wholeCbor['vfsDataList'].each do
         | 
| 188 | 
            +
                    #extremeZipOutputFile = File.new("comressed.#{processCounter}.cex", 'wb') # 创建文件
         | 
| 189 | 
            +
             | 
| 190 | 
            +
                    currentBlockFile = File.new("comressed.#{processCounter}.cex", 'rb') # 打开文件
         | 
| 191 | 
            +
             | 
| 192 | 
            +
                    wholeFileContent = currentBlockFile.read # 读取全部内容
         | 
| 193 | 
            +
             | 
| 194 | 
            +
                    currentBlockFile.close # 关闭文件
         | 
| 195 | 
            +
                    File.delete(currentBlockFile) # 删除数据块文件
         | 
| 196 | 
            +
             | 
| 197 | 
            +
                      #wholeFileContent=File.read("comressed.#{processCounter}.cex", 'rb') # 读取压缩块。
         | 
| 198 | 
            +
                      
         | 
| 199 | 
            +
                    puts "wirte file contetn length: #{wholeFileContent.length}" # Debghu
         | 
| 200 | 
            +
                      
         | 
| 201 | 
            +
                    extremeZipOutputFile.syswrite(wholeFileContent) # 写入文件
         | 
| 202 | 
            +
                      
         | 
| 203 | 
            +
                    processCounter += 1 # 计数
         | 
| 204 | 
            +
                  end
         | 
| 205 | 
            +
                    
         | 
| 206 | 
            +
                  extremeZipOutputFile.close # 关闭文件
         | 
| 207 | 
            +
                end
         | 
| 79 208 |  | 
| 80 209 | 
             
                # 写入文件内容
         | 
| 81 210 | 
             
                def writeFile(wholeFileContent, victoriaFresh)
         | 
| @@ -92,8 +221,16 @@ class ExtremeZip | |
| 92 221 | 
             
                        currentSubProcess=processIdList[processCounter] # 获取子进程对象
         | 
| 93 222 | 
             
                    #processIdList.each do |currentSubProcess|
         | 
| 94 223 | 
             
                        compressed = receiveFromSubProcess(currentSubProcess, responsePipeList, processCounter) # 从子进程中读取数据,并终止子进程
         | 
| 224 | 
            +
                        
         | 
| 225 | 
            +
                        #写入当前压缩块到文件系统中去作为缓存。陈欣
         | 
| 226 | 
            +
                        writeCompressBlock(compressed, processCounter) # 写入压缩块文件
         | 
| 227 | 
            +
                        
         | 
| 228 | 
            +
                        blockInfo={} # 块信息
         | 
| 229 | 
            +
                        blockInfo['length']=compressed.length # 记录长度
         | 
| 230 | 
            +
                        
         | 
| 231 | 
            +
                        puts "block length: #{blockInfo['length']}" # Debug
         | 
| 95 232 |  | 
| 96 | 
            -
                        @vfsDataList <<  | 
| 233 | 
            +
                        @vfsDataList << blockInfo # 加入数据块列表中
         | 
| 97 234 | 
             
                        checkMemoryUsage(150)
         | 
| 98 235 |  | 
| 99 236 | 
             
                        processCounter += 1 # 子进程计数
         | 
| @@ -112,7 +249,7 @@ class ExtremeZip | |
| 112 249 |  | 
| 113 250 | 
             
                    currentBlockFile.close # 关闭文件
         | 
| 114 251 |  | 
| 115 | 
            -
                     | 
| 252 | 
            +
                    File.delete(currentBlockFile) # 删除数据块文件
         | 
| 116 253 |  | 
| 117 254 | 
             
                    currentBlockData
         | 
| 118 255 | 
             
                end
         | 
| @@ -121,11 +258,8 @@ class ExtremeZip | |
| 121 258 | 
             
                def schedule1Block(filePartCounter)
         | 
| 122 259 | 
             
                    currentBlockData = readBlockFile(filePartCounter) # 读取块文件内容
         | 
| 123 260 |  | 
| 124 | 
            -
                    # currentTaskPipe = Cod.pipe # 任务分配管道
         | 
| 125 261 | 
             
                    currentResponsePipe = Cod.pipe # 任务回复管道
         | 
| 126 262 |  | 
| 127 | 
            -
                    puts("forking sub process, file part counter: #{filePartCounter}") # Debug.
         | 
| 128 | 
            -
             | 
| 129 263 | 
             
                    p1 = fork do # 复制出子进程
         | 
| 130 264 | 
             
                        compressInSubProcess(currentBlockData, currentResponsePipe) # 在子进程中具体执行的压缩代码
         | 
| 131 265 | 
             
                    end # p1 = fork do #复制出子进程
         | 
| @@ -146,11 +280,8 @@ class ExtremeZip | |
| 146 280 |  | 
| 147 281 | 
             
                # 启动子进程。
         | 
| 148 282 | 
             
                def launchSubProcesses
         | 
| 149 | 
            -
             | 
| 150 | 
            -
                    #while ((@filePartCounter < @filePartAmount) && (true)) # 未处理完毕,并且未达到最大子进程个数
         | 
| 151 283 | 
             
                    while ((@filePartCounter < @filePartAmount) && (@filePartCounter<@maxSubProcessAmount)) # 未处理完毕,并且未达到最大子进程个数
         | 
| 152 284 | 
             
                        currentResponsePipe, p1 = schedule1Block(@filePartCounter) # 计划一个块的压缩计算
         | 
| 153 | 
            -
             | 
| 154 285 | 
             
                    end # while processDataLength < victoriaFreshData.byte_size do #未处理完毕
         | 
| 155 286 |  | 
| 156 287 | 
             
                    [@processIdList, @responsePipeList]
         | 
| @@ -168,7 +299,6 @@ class ExtremeZip | |
| 168 299 |  | 
| 169 300 | 
             
                    currentResponsePipe.put currentCompressedVfsData # 将压缩后的数据块写入到回复管道中
         | 
| 170 301 |  | 
| 171 | 
            -
                    checkMemoryUsage(125)
         | 
| 172 302 | 
             
                    puts("finished #{Process.pid}") # Debug
         | 
| 173 303 | 
             
                end # compressInSubProcess(currentBlockData, currentResponsePipe)  # 在子进程中具体执行的压缩代码
         | 
| 174 304 |  | 
    
        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. | 
| 4 | 
            +
              version: 2022.2.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: 2022- | 
| 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. | 
| 89 | 
            +
                    version: 2022.2.19
         | 
| 90 90 | 
             
                - - ">="
         | 
| 91 91 | 
             
                  - !ruby/object:Gem::Version
         | 
| 92 | 
            -
                    version: 2022. | 
| 92 | 
            +
                    version: 2022.2.19
         | 
| 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. | 
| 99 | 
            +
                    version: 2022.2.19
         | 
| 100 100 | 
             
                - - ">="
         | 
| 101 101 | 
             
                  - !ruby/object:Gem::Version
         | 
| 102 | 
            -
                    version: 2022. | 
| 102 | 
            +
                    version: 2022.2.19
         | 
| 103 103 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 104 104 | 
             
              name: hx_cbor
         | 
| 105 105 | 
             
              requirement: !ruby/object:Gem::Requirement
         |