store_agent 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/README.md +4 -0
- data/Rakefile +3 -0
- data/lib/store_agent/config.rb +1 -3
- data/lib/store_agent/node/attachment/metadata.rb +0 -2
- data/lib/store_agent/node/object.rb +0 -6
- data/lib/store_agent/node/object/directory_object.rb +0 -6
- data/lib/store_agent/node/prepend_module/locker.rb +3 -3
- data/lib/store_agent/version.rb +1 -1
- data/lib/store_agent/version_manager/ruby_git.rb +7 -1
- data/lib/store_agent/version_manager/rugged_git.rb +2 -0
- data/lib/store_agent/workspace.rb +1 -1
- data/spec/spec_helper.rb +4 -3
- data/spec/store_agent/data_encoder_spec.rb +1 -1
- data/spec/store_agent/node/directory_object_spec.rb +9 -33
- data/spec/store_agent/node/locker_spec.rb +1 -1
- data/spec/store_agent/node/metadata_spec.rb +29 -29
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33dfc49f58f274a2db1bbb0dec2f0e98f2addada
|
4
|
+
data.tar.gz: 3e16e6582e9f8292868c557f5b4349b13b596ff5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 786a325359383c3db29ca0f7ac1e19d254201dbd5d3c9858300a1322251e2a6437d787cf9c920309036baaada29260bb6999dc27143d58218eff442745272fd0
|
7
|
+
data.tar.gz: 5803a7cde0d6e12b7af4880b5c7ecf090d9706b854bb5ad4e0d15ab1e94c93103a4aa13e145e85b2a7f320b6cf1dc2f7043ed6146f8dba49bdd33d86df1ba3be
|
data/.travis.yml
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/store_agent/config.rb
CHANGED
@@ -26,12 +26,6 @@ module StoreAgent
|
|
26
26
|
StoreAgent::Node::PermissionChecker <<
|
27
27
|
StoreAgent::Node::Locker
|
28
28
|
|
29
|
-
# def self.inherited(child)
|
30
|
-
# child.include StoreAgent::Node::Locker
|
31
|
-
# child.include StoreAgent::Node::PermissionChecker
|
32
|
-
# child.include StoreAgent::Node::PathValidator
|
33
|
-
# end
|
34
|
-
|
35
29
|
attr_reader :workspace, :path
|
36
30
|
def_delegators :workspace, *%w(current_user)
|
37
31
|
|
@@ -35,7 +35,6 @@ module StoreAgent
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
# TODO
|
39
38
|
def read(revision: nil)
|
40
39
|
super do
|
41
40
|
filenames =
|
@@ -207,11 +206,6 @@ module StoreAgent
|
|
207
206
|
metadata["tree_file_count"]
|
208
207
|
end
|
209
208
|
|
210
|
-
# TODO auth
|
211
|
-
def update_limit=(limit)
|
212
|
-
metadata["directory_bytes_limit"] = limit
|
213
|
-
end
|
214
|
-
|
215
209
|
def directory? # :nodoc:
|
216
210
|
true
|
217
211
|
end
|
@@ -78,9 +78,8 @@ module StoreAgent
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
# TODO
|
82
|
-
#
|
83
|
-
# 親階層のファイルをロックしていないので、同時にファイル削除などが実行されると問題が発生する可能性がある
|
81
|
+
# TODO
|
82
|
+
# 親階層のファイルをロックする
|
84
83
|
def set_permission(*)
|
85
84
|
lock!(lock_mode: File::LOCK_EX, recursive: false) do
|
86
85
|
super
|
@@ -88,6 +87,7 @@ module StoreAgent
|
|
88
87
|
end
|
89
88
|
|
90
89
|
# TODO
|
90
|
+
# 親階層のファイルをロックする
|
91
91
|
def unset_permission(*)
|
92
92
|
lock!(lock_mode: File::LOCK_EX, recursive: false) do
|
93
93
|
super
|
data/lib/store_agent/version.rb
CHANGED
@@ -27,6 +27,8 @@ module StoreAgent
|
|
27
27
|
def init
|
28
28
|
super do
|
29
29
|
Git.init
|
30
|
+
repository.config["user.name"] || repository.config("user.name", "test_user")
|
31
|
+
repository.config["user.email"] || repository.config("user.email", "test@example.com")
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -39,7 +41,11 @@ module StoreAgent
|
|
39
41
|
|
40
42
|
def remove(*paths, **_)
|
41
43
|
super do
|
42
|
-
|
44
|
+
# TODO fix
|
45
|
+
paths_string = paths.map{|path| relative_path(path)}.join(" ")
|
46
|
+
repository.chdir do
|
47
|
+
`git rm --cached -f -r #{paths_string}`
|
48
|
+
end
|
43
49
|
end
|
44
50
|
end
|
45
51
|
|
@@ -78,7 +78,7 @@ module StoreAgent
|
|
78
78
|
# 全ワークスペース名の一覧を配列で返す
|
79
79
|
def self.name_list
|
80
80
|
if !File.exists?(StoreAgent.config.storage_root)
|
81
|
-
FileUtils.
|
81
|
+
FileUtils.mkdir_p(StoreAgent.config.storage_root)
|
82
82
|
end
|
83
83
|
FileUtils.cd(StoreAgent.config.storage_root) do
|
84
84
|
return Dir.glob("*", File::FNM_DOTMATCH) - StoreAgent.reserved_filenames
|
data/spec/spec_helper.rb
CHANGED
@@ -7,6 +7,10 @@ SimpleCov.start do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
require "store_agent"
|
10
|
+
if !File.exists?(StoreAgent.config.storage_root)
|
11
|
+
FileUtils.mkdir_p(StoreAgent.config.storage_root)
|
12
|
+
end
|
13
|
+
$directory_bytesize = File.size(StoreAgent.config.storage_root)
|
10
14
|
|
11
15
|
RSpec.configure do |config|
|
12
16
|
config.expect_with :rspec do |expectations|
|
@@ -24,8 +28,6 @@ RSpec.configure do |config|
|
|
24
28
|
|
25
29
|
config.profile_examples = 10
|
26
30
|
config.order = :random
|
27
|
-
# config.order = "16118"
|
28
|
-
# config.fail_fast = true
|
29
31
|
|
30
32
|
Kernel.srand config.seed
|
31
33
|
|
@@ -36,7 +38,6 @@ RSpec.configure do |config|
|
|
36
38
|
"read" => true,
|
37
39
|
"write" => true,
|
38
40
|
"execute" => true,
|
39
|
-
# "chown" => true,
|
40
41
|
"chmod" => true
|
41
42
|
}
|
42
43
|
end
|
@@ -66,7 +66,7 @@ RSpec.describe StoreAgent::DataEncoder do
|
|
66
66
|
dir = workspace.directory("bitesize_test").create
|
67
67
|
file = workspace.file("bitesize_test/hoge.txt").create("12 byte file")
|
68
68
|
expect(file.metadata["bytes"]).to eq 12
|
69
|
-
expect(workspace.directory("bitesize_test").metadata.disk_usage).to eq
|
69
|
+
expect(workspace.directory("bitesize_test").metadata.disk_usage).to eq ($directory_bytesize + 12)
|
70
70
|
end
|
71
71
|
it "パーミッション情報は gzip -c ... | openssl ... でエンコードされた形式で保存される" do
|
72
72
|
file = workspace.file("foo/bar.txt")
|
@@ -99,30 +99,6 @@ RSpec.describe StoreAgent::Node::DirectoryObject do
|
|
99
99
|
workspace.directory(".keep").create
|
100
100
|
expect(workspace.directory(".keep").exists?).to be true
|
101
101
|
end
|
102
|
-
it "引数にブロックを渡してdirectory_bytes_limitを初期化できる" do
|
103
|
-
pending
|
104
|
-
|
105
|
-
workspace.directory("limit").create do |d|
|
106
|
-
d..metadata["directory_bytes_limit"] = 12345678
|
107
|
-
end
|
108
|
-
expect(workspace.directory("limit").metadata["directory_bytes_limit"]).to eq 12345678
|
109
|
-
end
|
110
|
-
it "引数にブロックを渡してオーナーを初期化できる" do
|
111
|
-
skip "とりあえず保留"
|
112
|
-
|
113
|
-
StoreAgent::Superuser.new.workspace(workspace_name).directory("chown").create do |d|
|
114
|
-
d.initial_owner = "initial_owner"
|
115
|
-
end
|
116
|
-
expect(workspace.directory("chown").metadata["owner"]).to eq "initial_owner"
|
117
|
-
end
|
118
|
-
it "引数にブロックを渡して権限を初期化できる" do
|
119
|
-
pending
|
120
|
-
|
121
|
-
workspace.directory("chmod").create do |d|
|
122
|
-
d.initial_permission = {"readwrite" => true}
|
123
|
-
end
|
124
|
-
expect(workspace.directory("chmod").permission).to eq ({"readwrite" => true})
|
125
|
-
end
|
126
102
|
end
|
127
103
|
|
128
104
|
context "ディレクトリ削除のテスト" do
|
@@ -184,8 +160,8 @@ RSpec.describe StoreAgent::Node::DirectoryObject do
|
|
184
160
|
workspace.directory("/")
|
185
161
|
end
|
186
162
|
|
187
|
-
it "ディスク使用量は
|
188
|
-
expect(root_node.metadata.disk_usage).to eq ((
|
163
|
+
it "ディスク使用量は #{$directory_bytesize} * 4 + 30 バイト" do
|
164
|
+
expect(root_node.metadata.disk_usage).to eq (($directory_bytesize * 4) + 30)
|
189
165
|
end
|
190
166
|
it "直下のファイル数は 1" do
|
191
167
|
expect(root_node.directory_file_count).to eq 1
|
@@ -199,8 +175,8 @@ RSpec.describe StoreAgent::Node::DirectoryObject do
|
|
199
175
|
workspace.directory("/delete_test")
|
200
176
|
end
|
201
177
|
|
202
|
-
it "ディスク使用量は
|
203
|
-
expect(dir.metadata.disk_usage).to eq ((
|
178
|
+
it "ディスク使用量は #{$directory_bytesize} * 3 + 30 バイト" do
|
179
|
+
expect(dir.metadata.disk_usage).to eq (($directory_bytesize * 3) + 30)
|
204
180
|
end
|
205
181
|
it "直下のファイル数は 2" do
|
206
182
|
expect(dir.directory_file_count).to eq 2
|
@@ -214,8 +190,8 @@ RSpec.describe StoreAgent::Node::DirectoryObject do
|
|
214
190
|
workspace.directory("/delete_test/bar")
|
215
191
|
end
|
216
192
|
|
217
|
-
it "ディスク使用量は
|
218
|
-
expect(dir.metadata.disk_usage).to eq (
|
193
|
+
it "ディスク使用量は #{$directory_bytesize} + 10 バイト" do
|
194
|
+
expect(dir.metadata.disk_usage).to eq ($directory_bytesize + 10)
|
219
195
|
end
|
220
196
|
it "直下のファイル数は 1" do
|
221
197
|
expect(dir.directory_file_count).to eq 1
|
@@ -229,8 +205,8 @@ RSpec.describe StoreAgent::Node::DirectoryObject do
|
|
229
205
|
workspace.directory("/delete_test/foobar")
|
230
206
|
end
|
231
207
|
|
232
|
-
it "ディスク使用量は
|
233
|
-
expect(dir.metadata.disk_usage).to eq (
|
208
|
+
it "ディスク使用量は #{$directory_bytesize} + 20 バイト" do
|
209
|
+
expect(dir.metadata.disk_usage).to eq ($directory_bytesize + 20)
|
234
210
|
end
|
235
211
|
it "直下のファイル数は 1" do
|
236
212
|
expect(dir.directory_file_count).to eq 1
|
@@ -337,7 +313,7 @@ RSpec.describe StoreAgent::Node::DirectoryObject do
|
|
337
313
|
prev_bytesize = workspace.directory("copy").metadata["directory_bytes"]
|
338
314
|
src_dir.copy(dest_directory_path)
|
339
315
|
expect(workspace.directory(dest_directory_path).file("src/foo.txt").read).to eq "copy"
|
340
|
-
expect(workspace.directory("copy").metadata["directory_bytes"]).to eq prev_bytesize +
|
316
|
+
expect(workspace.directory("copy").metadata["directory_bytes"]).to eq prev_bytesize + $directory_bytesize + 4
|
341
317
|
expect(workspace.directory("copy").tree_file_count).to eq prev_count + 2
|
342
318
|
end
|
343
319
|
it "コピー先のディレクトリ内に同名のファイルが存在する場合、例外が発生する" do
|
@@ -42,8 +42,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
42
42
|
it "JSON形式で保存される" do
|
43
43
|
expect(open(@root_node.metadata.file_path).read).to eq @root_node.metadata.inspect
|
44
44
|
end
|
45
|
-
it "ルートディレクトリの使用容量は
|
46
|
-
expect(@root_node.metadata.disk_usage).to eq
|
45
|
+
it "ルートディレクトリの使用容量は #{$directory_bytesize} バイト" do
|
46
|
+
expect(@root_node.metadata.disk_usage).to eq $directory_bytesize
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -72,8 +72,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
context "ルートディレクトリ" do
|
75
|
-
it "ディスク使用量は (
|
76
|
-
expect(@root_node.metadata.disk_usage).to eq (
|
75
|
+
it "ディスク使用量は (#{$directory_bytesize} * 3) バイト" do
|
76
|
+
expect(@root_node.metadata.disk_usage).to eq ($directory_bytesize * 3)
|
77
77
|
end
|
78
78
|
it "直下のファイル数は 1" do
|
79
79
|
expect(@root_node.directory_file_count).to eq 1
|
@@ -83,8 +83,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
context "中間ディレクトリ" do
|
86
|
-
it "ディスク使用量は (
|
87
|
-
expect(@dir_1.metadata.disk_usage).to eq (
|
86
|
+
it "ディスク使用量は (#{$directory_bytesize} * 2) バイト" do
|
87
|
+
expect(@dir_1.metadata.disk_usage).to eq ($directory_bytesize * 2)
|
88
88
|
end
|
89
89
|
it "直下のファイル数は 1" do
|
90
90
|
expect(@dir_1.directory_file_count).to eq 1
|
@@ -94,8 +94,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
context "最下層のディレクトリ" do
|
97
|
-
it "ディスク使用量は
|
98
|
-
expect(@dir_2.metadata.disk_usage).to eq
|
97
|
+
it "ディスク使用量は #{$directory_bytesize} バイト" do
|
98
|
+
expect(@dir_2.metadata.disk_usage).to eq $directory_bytesize
|
99
99
|
end
|
100
100
|
it "直下のファイル数は 0" do
|
101
101
|
expect(@dir_2.directory_file_count).to eq 0
|
@@ -122,8 +122,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
122
122
|
end
|
123
123
|
|
124
124
|
context "ルートディレクトリ" do
|
125
|
-
it "ディスク使用量は (
|
126
|
-
expect(@root_node.metadata.disk_usage).to eq ((
|
125
|
+
it "ディスク使用量は (#{$directory_bytesize} * 2) + 10 バイト" do
|
126
|
+
expect(@root_node.metadata.disk_usage).to eq (($directory_bytesize * 2) + 10)
|
127
127
|
end
|
128
128
|
it "直下のファイル数は 1" do
|
129
129
|
expect(@root_node.directory_file_count).to eq 1
|
@@ -133,8 +133,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
context "ディレクトリ" do
|
136
|
-
it "ディスク使用量は
|
137
|
-
expect(@dir.metadata.disk_usage).to eq (
|
136
|
+
it "ディスク使用量は #{$directory_bytesize} + 10 バイト" do
|
137
|
+
expect(@dir.metadata.disk_usage).to eq ($directory_bytesize + 10)
|
138
138
|
end
|
139
139
|
it "直下のファイル数は 1" do
|
140
140
|
expect(@dir.directory_file_count).to eq 1
|
@@ -175,8 +175,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
175
175
|
end
|
176
176
|
|
177
177
|
context "ルートディレクトリ" do
|
178
|
-
it "ディスク使用量は (
|
179
|
-
expect(@root_node.metadata.disk_usage).to eq ((
|
178
|
+
it "ディスク使用量は (#{$directory_bytesize} * 2) + 7 バイト" do
|
179
|
+
expect(@root_node.metadata.disk_usage).to eq (($directory_bytesize * 2) + 7)
|
180
180
|
end
|
181
181
|
it "直下のファイル数は 1" do
|
182
182
|
expect(@root_node.directory_file_count).to eq 1
|
@@ -186,8 +186,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
186
186
|
end
|
187
187
|
end
|
188
188
|
context "ディレクトリ" do
|
189
|
-
it "ディスク使用量は
|
190
|
-
expect(@dir.metadata.disk_usage).to eq (
|
189
|
+
it "ディスク使用量は #{$directory_bytesize} + 7 バイト" do
|
190
|
+
expect(@dir.metadata.disk_usage).to eq ($directory_bytesize + 7)
|
191
191
|
end
|
192
192
|
it "直下のファイル数は 1" do
|
193
193
|
expect(@dir.directory_file_count).to eq 1
|
@@ -228,8 +228,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
228
228
|
end
|
229
229
|
|
230
230
|
context "ルートディレクトリ" do
|
231
|
-
it "ディスク使用量は (
|
232
|
-
expect(@root_node.metadata.disk_usage).to eq ((
|
231
|
+
it "ディスク使用量は (#{$directory_bytesize} * 2) + 10 バイト" do
|
232
|
+
expect(@root_node.metadata.disk_usage).to eq (($directory_bytesize * 2) + 10)
|
233
233
|
end
|
234
234
|
it "直下のファイル数は 1" do
|
235
235
|
expect(@root_node.directory_file_count).to eq 1
|
@@ -239,8 +239,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
239
239
|
end
|
240
240
|
end
|
241
241
|
context "ディレクトリ" do
|
242
|
-
it "ディスク使用量は
|
243
|
-
expect(@dir.metadata.disk_usage).to eq (
|
242
|
+
it "ディスク使用量は #{$directory_bytesize} + 10 バイト" do
|
243
|
+
expect(@dir.metadata.disk_usage).to eq ($directory_bytesize + 10)
|
244
244
|
end
|
245
245
|
it "直下のファイル数は 1" do
|
246
246
|
expect(@dir.directory_file_count).to eq 1
|
@@ -252,7 +252,7 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
252
252
|
file = owner.workspace(workspace_name).file("foo/foobarhoge.txt").create("body" => "0987654321")
|
253
253
|
file.body = ""
|
254
254
|
file.delete
|
255
|
-
expect(@dir.metadata.disk_usage).to eq (
|
255
|
+
expect(@dir.metadata.disk_usage).to eq ($directory_bytesize + 10)
|
256
256
|
end
|
257
257
|
end
|
258
258
|
end
|
@@ -273,8 +273,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
273
273
|
end
|
274
274
|
|
275
275
|
context "ルートディレクトリ" do
|
276
|
-
it "ディスク使用量は
|
277
|
-
expect(@root_node.metadata.disk_usage).to eq (
|
276
|
+
it "ディスク使用量は #{$directory_bytesize} * 2 バイト" do
|
277
|
+
expect(@root_node.metadata.disk_usage).to eq ($directory_bytesize * 2)
|
278
278
|
end
|
279
279
|
it "直下のファイル数は 1" do
|
280
280
|
expect(@root_node.directory_file_count).to eq 1
|
@@ -284,8 +284,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
284
284
|
end
|
285
285
|
end
|
286
286
|
context "ディレクトリ" do
|
287
|
-
it "ディスク使用量は
|
288
|
-
expect(@dir.metadata.disk_usage).to eq
|
287
|
+
it "ディスク使用量は #{$directory_bytesize} バイト" do
|
288
|
+
expect(@dir.metadata.disk_usage).to eq $directory_bytesize
|
289
289
|
end
|
290
290
|
it "直下のファイル数は 0" do
|
291
291
|
expect(@dir.directory_file_count).to eq 0
|
@@ -314,8 +314,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
314
314
|
end
|
315
315
|
|
316
316
|
context "ルートディレクトリ" do
|
317
|
-
it "ディスク使用量は
|
318
|
-
expect(@root_node.metadata.disk_usage).to eq (
|
317
|
+
it "ディスク使用量は #{$directory_bytesize} * 2 バイト" do
|
318
|
+
expect(@root_node.metadata.disk_usage).to eq ($directory_bytesize * 2)
|
319
319
|
end
|
320
320
|
it "直下のファイル数は 1" do
|
321
321
|
expect(@root_node.directory_file_count).to eq 1
|
@@ -325,8 +325,8 @@ RSpec.describe StoreAgent::Node::Metadata do
|
|
325
325
|
end
|
326
326
|
end
|
327
327
|
context "ディレクトリ" do
|
328
|
-
it "ディスク使用量は
|
329
|
-
expect(@dir.metadata.disk_usage).to eq
|
328
|
+
it "ディスク使用量は #{$directory_bytesize} バイト" do
|
329
|
+
expect(@dir.metadata.disk_usage).to eq $directory_bytesize
|
330
330
|
end
|
331
331
|
it "直下のファイル数は 0" do
|
332
332
|
expect(@dir.directory_file_count).to eq 0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: store_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- realglobe-Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -159,6 +159,7 @@ extra_rdoc_files: []
|
|
159
159
|
files:
|
160
160
|
- ".gitignore"
|
161
161
|
- ".rspec"
|
162
|
+
- ".travis.yml"
|
162
163
|
- Gemfile
|
163
164
|
- Guardfile
|
164
165
|
- LICENSE
|