VictoriaFreSh 2020.8.28 → 2020.10.31

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 +32 -24
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3584c33ba89a128cba749bdd3f40999487bd3b752f74b0fef2185f4de4cccc8
4
- data.tar.gz: a02a0a68b46bcb9dd2bdf66cddb8364e7d267172cc3ebf0e65178ffc8d7838e2
3
+ metadata.gz: 3e3f7b0d2274b3e4d1053b1ea06d25d0136a9d4cf877a76dd802c4ea89d0b1b7
4
+ data.tar.gz: c3723184467e8e953fcd01cacb7c02a7cc1c77a43f1cf7bfe47b81ad41d8ca3e
5
5
  SHA512:
6
- metadata.gz: c7daf3a023afb9d6190c57db4fbda022a8b191dba03c7a579ee40200f1d5a60b75524acaced3721ebfbc42ddd500b07a1622c9d82f4e309a69a6a4f1b0f80dca
7
- data.tar.gz: d10c9cd621aac4017795dd36157db9f2264d5ed4b7db9812d84d86bcc46db34a9536aedbf19bbd161a37fd10f437d91d7f91c0a5baf644e95a3d5631f2725877
6
+ metadata.gz: 27ffe0e19351ed1e013465dde4cf4c1adbe16ccef807319feea079880c7f0827bc460ec6e5f6d8d90c261189796e9aae48ab9cd4c9bfc033c79c0b774640480c
7
+ data.tar.gz: b03f697db6128b7d582d3c491c67d0c3950d7a8937b8562e5e1510170ba41d5115017aedee13eeaa574ef50d3e49558864cb87f6d4cae87138f824da472dc71b
@@ -27,12 +27,19 @@ 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
  #创建符号链接
@@ -51,6 +58,18 @@ class VictoriaFresh
51
58
  puts("data: #{victoriaFreshData}, path: #{pathToMake}") #Debug
52
59
 
53
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?) #不带权限字段
54
73
  end #def makeSymlink(pathPrefix, packagedFile, contentString) #创建符号链接
55
74
 
56
75
  def getTimeObject(packagedFile) #构造时间戳对象
@@ -68,12 +87,12 @@ class VictoriaFresh
68
87
  timeObject=getTimeObject(packagedFile) #构造时间戳对象
69
88
 
70
89
 
71
- puts 'mkdir' #Debug
90
+ # puts 'mkdir' #Debug
72
91
 
73
92
  # pathToMake=File.join(pathPrefix, packagedFile.name)
74
93
  pathToMake=File.join(pathPrefix, packagedFile['name'])
75
94
 
76
- puts pathToMake #Debug.
95
+ # puts pathToMake #Debug.
77
96
 
78
97
  if (Dir.exist?(pathToMake)) #目录已经存在
79
98
  else #目录 不存在
@@ -82,29 +101,25 @@ class VictoriaFresh
82
101
 
83
102
 
84
103
  FileUtils.touch pathToMake, :mtime => timeObject #设置修改时间
85
-
104
+
105
+ permissionNumber=packagedFile['permission'] #获取权限数字
106
+
107
+ if (permissionNumber.nil?) #不带权限字段
108
+ elsif #带权限字段
109
+ File.chmod(permissionNumber, pathToMake) #设置权限
110
+ end #if (permissionNumber.nil?) #不带权限字段
86
111
  end #makeDirectory(pathPrefix, packagedFile) #创建目录
87
112
 
88
113
  def releaseFile( pathPrefix, packagedFile, contentString) #释放一个文件
89
- # puts packagedFile.name #Debug
90
- puts packagedFile['name'] #Debug
91
- puts("content stirng length: #{contentString.bytesize}") #Debug
92
- # puts packagedFile.timestamp #Debug
93
- puts packagedFile['timestamp'] #Debug
94
-
95
- # if packagedFile.is_file #是文件,则直接写入文件
96
114
  if packagedFile['is_file'] #是文件,则直接写入文件
97
115
  writeFile(pathPrefix, packagedFile, contentString) #写入文件
98
116
  elsif packagedFile['is_symlink'] #是符号链接,则创建符号链接
99
117
  makeSymlink(pathPrefix, packagedFile, contentString) #创建符号链接
100
- # writeFile(pathPrefix, packagedFile, contentString) #写入文件
101
118
  else #是目录,则创建目录,并递归处理
102
119
  makeDirectory(pathPrefix, packagedFile) #创建目录
103
120
 
104
- # direcotryPathPrefix=pathPrefix + '/' + packagedFile.name #构造针对该目录的路径前缀
105
121
  direcotryPathPrefix=pathPrefix + '/' + packagedFile['name'] #构造针对该目录的路径前缀
106
122
 
107
- # subFiles=packagedFile.sub_files #获取子文件列表。
108
123
  subFiles=packagedFile['sub_files'] #获取子文件列表。
109
124
 
110
125
  subFiles.each do |currentSubFile| #一个个子文件地释放
@@ -115,16 +130,10 @@ class VictoriaFresh
115
130
  end #def releaseFile(packagedFile, contentString) #释放一个文件
116
131
 
117
132
  def checkOnce(directoryPath,startIndex=0) #打包一个目录树。
118
- # packagedFile=Com::Stupidbeauty::Victoriafresh::FileMessage.new #创建文件消息对象。
119
133
  packagedFile={} #创建文件消息对象。
120
134
 
121
- # packagedFile.sub_files=[] #初始化数组。
122
135
  packagedFile['sub_files'] = [] #加入到子文件列表中。
123
136
 
124
- # packagedFile.sub_files=Google::Protobuf::RepeatedField.new(Com::Stupidbeauty::Victoriafresh::FileMessage, []) #初始化数组
125
- # packagedFile.sub_files=Google::Protobuf::RepeatedField.new(Google::Protobuf::DescriptorPool.generated_pool.lookup("com.stupidbeauty.victoriafresh.FileMessage").msgclass, []) #初始化数组
126
-
127
-
128
137
  directoryPathName=Pathname.new(directoryPath) #构造路径名字对象。
129
138
 
130
139
  baseName=directoryPathName.basename.to_s #基本文件名。
@@ -144,17 +153,16 @@ class VictoriaFresh
144
153
  #记录时间戳:
145
154
  begin #读取时间戳
146
155
  mtimeStamp=File.mtime(directoryPath) #获取时间戳
147
- # puts mtimeStamp #Debug
148
156
 
149
157
  packagedFile['timestamp']={} #时间戳
150
158
  packagedFile['timestamp']['seconds']=mtimeStamp.tv_sec #设置秒数
151
159
  packagedFile['timestamp']['nanos']=mtimeStamp.tv_nsec #设置纳秒数
152
-
160
+
161
+ packagedFile['permission']=(File.stat(directoryPath).mode & 07777 ) #设置权限信息
153
162
  rescue Errno::ENOENT
154
-
163
+ rescue Errno::EACCES #权限受限
155
164
  end #begin #读取时间戳
156
165
 
157
-
158
166
  if (isFile) #是文件,不用再列出其子文件了。
159
167
  packagedFile['file_length']=directoryPathName.size #记录文件的内容长度。
160
168
 
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.28
4
+ version: 2020.10.31
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-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cbor