VictoriaFreSh 2020.8.24 → 2020.10.24

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 +37 -16
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f11c77fa1613f7abb1115e42cc3803c042efc756346c0053d17a8aa33a1a3589
4
- data.tar.gz: e45655df3304cee4c976cb663734cb9fd75a373369c16ceb06fb0eb78edbd334
3
+ metadata.gz: 0742d069cda4361d3f90519ba1cb187d40ecbf08707bae998439a956d4bd6f93
4
+ data.tar.gz: 1b37ab4205b6b0f9dbe681cbe3c7e997e1758f7dfb80688c9606a6fcfba08a75
5
5
  SHA512:
6
- metadata.gz: 1227d165836ad8b3c3d19fd1eb91f886d3cd7401cc087d5c0e4fd6c22208573f79bbd222422496465524975455315aebea5648b8aed6b7a9c0bf188d08abd4d1
7
- data.tar.gz: c7aa3118a9204ca443e70c4b67552c8bdd17f998f5ee45188b097f2a1da40998e61945d7cc09f96e019acd43b2861b8e840d3dce266f551539e45d2ae3ded669
6
+ metadata.gz: 1da8a95eddc0a0a30e6878fb808a9b5e1d28c4afd3e9a4dc20e198993b30d57f4996dcf486cf471a0f249fc5e2ec6c3ace720363f6a724625e6a286e764a2c97
7
+ data.tar.gz: f75aa4b8fd9e05468dcb76e77064229a674b81c081a44093430145573d9d679530103e8947567fabb685ca28c523831b088b09c6a9ce799205d56939358c406d
@@ -27,16 +27,24 @@ class VictoriaFresh
27
27
  # pathToMake=pathPrefix + '/' + packagedFile.name #构造文件名
28
28
  pathToMake=pathPrefix + '/' + packagedFile['name'] #构造文件名
29
29
 
30
- victoriaFreshDataFile=File.new(pathToMake , "wb") #数据文件。
30
+ victoriaFreshDataFile=File.new(pathToMake , "wb", packagedFile['permission']) #数据文件。
31
31
  victoriaFreshDataFile.syswrite(victoriaFreshData) #写入文件。
32
32
  victoriaFreshDataFile.close #关闭文件。
33
33
 
34
34
  FileUtils.touch pathToMake, :mtime => timeObject #设置修改时间
35
35
 
36
+ permissionNumber=packagedFile['permission'] #获取权限数字
37
+
38
+ if (permissionNumber.nil?) #不带权限字段
39
+ elsif #带权限字段
40
+ File.chmod(permissionNumber, pathToMake) #设置权限
41
+ end #if (permissionNumber.nil?) #不带权限字段
42
+
36
43
  end #writeFile(pathPrefix, packagedFile, contentString) #写入文件
37
44
 
38
45
  #创建符号链接
39
46
  def makeSymlink(pathPrefix, packagedFile, contentString)
47
+ puts("start index: #{packagedFile['file_start_index']}, length: #{packagedFile['file_length']}, content string length: #{contentString.bytesize}") #Debug
40
48
  victoriaFreshData=contentString[ packagedFile['file_start_index'], packagedFile['file_length'] ] #获取内容
41
49
 
42
50
  pathToMake=pathPrefix + '/' + packagedFile['name'] #构造文件名
@@ -47,7 +55,21 @@ class VictoriaFresh
47
55
  #
48
56
  # FileUtils.touch pathToMake, :mtime => timeObject #设置修改时间
49
57
 
58
+ puts("data: #{victoriaFreshData}, path: #{pathToMake}") #Debug
59
+
50
60
  FileUtils.symlink(victoriaFreshData, pathToMake, force: true) #创建符号链接
61
+
62
+ permissionNumber=packagedFile['permission'] #获取权限数字
63
+
64
+ if (permissionNumber.nil?) #不带权限字段
65
+ elsif #带权限字段
66
+ # File.chmod(permissionNumber, pathToMake) #设置权限
67
+ begin #尝试修改链接本身的权限
68
+ File.lchmod(permissionNumber, pathToMake) #设置权限
69
+ rescue NotImplementedError #未实现
70
+ puts 'File.lchmod not implemented' #Debug
71
+ end #begin #尝试修改链接本身的权限
72
+ end #if (permissionNumber.nil?) #不带权限字段
51
73
  end #def makeSymlink(pathPrefix, packagedFile, contentString) #创建符号链接
52
74
 
53
75
  def getTimeObject(packagedFile) #构造时间戳对象
@@ -65,12 +87,12 @@ class VictoriaFresh
65
87
  timeObject=getTimeObject(packagedFile) #构造时间戳对象
66
88
 
67
89
 
68
- puts 'mkdir' #Debug
90
+ # puts 'mkdir' #Debug
69
91
 
70
92
  # pathToMake=File.join(pathPrefix, packagedFile.name)
71
93
  pathToMake=File.join(pathPrefix, packagedFile['name'])
72
94
 
73
- puts pathToMake #Debug.
95
+ # puts pathToMake #Debug.
74
96
 
75
97
  if (Dir.exist?(pathToMake)) #目录已经存在
76
98
  else #目录 不存在
@@ -79,13 +101,19 @@ class VictoriaFresh
79
101
 
80
102
 
81
103
  FileUtils.touch pathToMake, :mtime => timeObject #设置修改时间
82
-
104
+
105
+ permissionNumber=packagedFile['permission'] #获取权限数字
106
+
107
+ if (permissionNumber.nil?) #不带权限字段
108
+ elsif #带权限字段
109
+ File.chmod(permissionNumber, pathToMake) #设置权限
110
+ end #if (permissionNumber.nil?) #不带权限字段
83
111
  end #makeDirectory(pathPrefix, packagedFile) #创建目录
84
112
 
85
113
  def releaseFile( pathPrefix, packagedFile, contentString) #释放一个文件
86
114
  # puts packagedFile.name #Debug
87
- puts packagedFile['name'] #Debug
88
-
115
+ # puts packagedFile['name'] #Debug
116
+ # puts("content stirng length: #{contentString.bytesize}") #Debug
89
117
  # puts packagedFile.timestamp #Debug
90
118
  puts packagedFile['timestamp'] #Debug
91
119
 
@@ -112,16 +140,10 @@ class VictoriaFresh
112
140
  end #def releaseFile(packagedFile, contentString) #释放一个文件
113
141
 
114
142
  def checkOnce(directoryPath,startIndex=0) #打包一个目录树。
115
- # packagedFile=Com::Stupidbeauty::Victoriafresh::FileMessage.new #创建文件消息对象。
116
143
  packagedFile={} #创建文件消息对象。
117
144
 
118
- # packagedFile.sub_files=[] #初始化数组。
119
145
  packagedFile['sub_files'] = [] #加入到子文件列表中。
120
146
 
121
- # packagedFile.sub_files=Google::Protobuf::RepeatedField.new(Com::Stupidbeauty::Victoriafresh::FileMessage, []) #初始化数组
122
- # packagedFile.sub_files=Google::Protobuf::RepeatedField.new(Google::Protobuf::DescriptorPool.generated_pool.lookup("com.stupidbeauty.victoriafresh.FileMessage").msgclass, []) #初始化数组
123
-
124
-
125
147
  directoryPathName=Pathname.new(directoryPath) #构造路径名字对象。
126
148
 
127
149
  baseName=directoryPathName.basename.to_s #基本文件名。
@@ -141,17 +163,16 @@ class VictoriaFresh
141
163
  #记录时间戳:
142
164
  begin #读取时间戳
143
165
  mtimeStamp=File.mtime(directoryPath) #获取时间戳
144
- # puts mtimeStamp #Debug
145
166
 
146
167
  packagedFile['timestamp']={} #时间戳
147
168
  packagedFile['timestamp']['seconds']=mtimeStamp.tv_sec #设置秒数
148
169
  packagedFile['timestamp']['nanos']=mtimeStamp.tv_nsec #设置纳秒数
149
-
170
+
171
+ packagedFile['permission']=(File.stat(directoryPath).mode & 07777 ) #设置权限信息
150
172
  rescue Errno::ENOENT
151
-
173
+ rescue Errno::EACCES #权限受限
152
174
  end #begin #读取时间戳
153
175
 
154
-
155
176
  if (isFile) #是文件,不用再列出其子文件了。
156
177
  packagedFile['file_length']=directoryPathName.size #记录文件的内容长度。
157
178
 
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: 2020.8.24
4
+ version: 2020.10.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hxcan Cai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-24 00:00:00.000000000 Z
11
+ date: 2020-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cbor