VictoriaFreSh 2020.7.38 → 2020.7.43
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 +30 -16
- 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: 3cd9a3ba2ec266174958ab7fed3a2dfba2656ffb0b0833742fb91fe078a28617
|
4
|
+
data.tar.gz: 44f60f5f60c7d0126a5994e1ba99afa435a2c153a4a84d46dd9406ddf0bbb9b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 965aea54528d639258d17c780a28160fb33d4043f026eb000c3c1ad51e5b11960c3655b2b5b96ad1c1fe02e926417603560eadbaca2d42b436380573883ce233
|
7
|
+
data.tar.gz: ae2bbe7ab8f2a894af168acbebbe9e6861bd2e46baf5fe19d65049d986575848f3d27fe9fbf6e0827e9c604d1814b21e26e3921737e5455601c6405a32bac8eb
|
data/lib/victoriafresh.rb
CHANGED
@@ -8,7 +8,9 @@ require 'cbor'
|
|
8
8
|
|
9
9
|
class VictoriaFresh
|
10
10
|
def releaseFiles(victoriaFreshPackagedFileString, contentString) #释放目录树
|
11
|
-
|
11
|
+
# packagedFile=Com::Stupidbeauty::Victoriafresh::FileMessage.decode(victoriaFreshPackagedFileString) #解码文件消息对象。
|
12
|
+
packagedFile=CBOR.decode(victoriaFreshPackagedFileString) #解码
|
13
|
+
|
12
14
|
|
13
15
|
puts packagedFile #Debug
|
14
16
|
|
@@ -19,23 +21,29 @@ class VictoriaFresh
|
|
19
21
|
|
20
22
|
timeObject=getTimeObject(packagedFile) #构造时间戳对象
|
21
23
|
|
22
|
-
victoriaFreshData=contentString[packagedFile.file_start_index, packagedFile.file_length] #获取内容
|
24
|
+
# victoriaFreshData=contentString[packagedFile.file_start_index, packagedFile.file_length] #获取内容
|
25
|
+
victoriaFreshData=contentString[ packagedFile['file_start_index'], packagedFile['file_length'] ] #获取内容
|
23
26
|
|
24
|
-
pathToMake=pathPrefix + '/' + packagedFile.name #构造文件名
|
27
|
+
# pathToMake=pathPrefix + '/' + packagedFile.name #构造文件名
|
28
|
+
pathToMake=pathPrefix + '/' + packagedFile['name'] #构造文件名
|
25
29
|
|
26
|
-
|
27
|
-
|
30
|
+
victoriaFreshDataFile=File.new(pathToMake , "wb") #数据文件。
|
31
|
+
victoriaFreshDataFile.syswrite(victoriaFreshData) #写入文件。
|
28
32
|
victoriaFreshDataFile.close #关闭文件。
|
29
|
-
|
33
|
+
|
30
34
|
FileUtils.touch pathToMake, :mtime => timeObject #设置修改时间
|
31
|
-
|
35
|
+
|
32
36
|
end #writeFile(pathPrefix, packagedFile, contentString) #写入文件
|
33
37
|
|
34
38
|
def getTimeObject(packagedFile) #构造时间戳对象
|
35
|
-
|
39
|
+
# puts packagedFile.timestamp #Debug
|
40
|
+
puts packagedFile['timestamp'] #Debug
|
36
41
|
|
37
|
-
|
38
|
-
|
42
|
+
# seconds=packagedFile.timestamp.seconds #获取秒数
|
43
|
+
seconds=packagedFile['timestamp']['seconds'] #获取秒数
|
44
|
+
|
45
|
+
# microSeconds=packagedFile.timestamp.nanos/ 1000.0 #获取毫秒数
|
46
|
+
microSeconds=packagedFile['timestamp']['nanos'] / 1000.0 #获取毫秒数
|
39
47
|
|
40
48
|
timeObject=Time.at(seconds, microSeconds) #构造时间对象
|
41
49
|
|
@@ -47,7 +55,8 @@ class VictoriaFresh
|
|
47
55
|
|
48
56
|
puts 'mkdir' #Debug
|
49
57
|
|
50
|
-
|
58
|
+
# pathToMake=File.join(pathPrefix, packagedFile.name)
|
59
|
+
pathToMake=File.join(pathPrefix, packagedFile['name'])
|
51
60
|
|
52
61
|
puts pathToMake #Debug.
|
53
62
|
|
@@ -62,18 +71,23 @@ class VictoriaFresh
|
|
62
71
|
end #makeDirectory(pathPrefix, packagedFile) #创建目录
|
63
72
|
|
64
73
|
def releaseFile( pathPrefix, packagedFile, contentString) #释放一个文件
|
65
|
-
|
74
|
+
# puts packagedFile.name #Debug
|
75
|
+
puts packagedFile['name'] #Debug
|
66
76
|
|
67
|
-
|
77
|
+
# puts packagedFile.timestamp #Debug
|
78
|
+
puts packagedFile['timestamp'] #Debug
|
68
79
|
|
69
|
-
|
80
|
+
# if packagedFile.is_file #是文件,则直接写入文件
|
81
|
+
if packagedFile['is_file'] #是文件,则直接写入文件
|
70
82
|
writeFile(pathPrefix, packagedFile, contentString) #写入文件
|
71
83
|
else #是目录,则创建目录,并递归处理
|
72
84
|
makeDirectory(pathPrefix, packagedFile) #创建目录
|
73
85
|
|
74
|
-
|
86
|
+
# direcotryPathPrefix=pathPrefix + '/' + packagedFile.name #构造针对该目录的路径前缀
|
87
|
+
direcotryPathPrefix=pathPrefix + '/' + packagedFile['name'] #构造针对该目录的路径前缀
|
75
88
|
|
76
|
-
|
89
|
+
# subFiles=packagedFile.sub_files #获取子文件列表。
|
90
|
+
subFiles=packagedFile['sub_files'] #获取子文件列表。
|
77
91
|
|
78
92
|
subFiles.each do |currentSubFile| #一个个子文件地释放
|
79
93
|
releaseFile(direcotryPathPrefix, currentSubFile, contentString) #释放子文件
|