file_pool 0.4.0 → 0.5.0
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/file_pool.rb +30 -7
- data/lib/file_pool/version.rb +1 -1
- metadata +21 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92b693e812622ddf1df122afe233c2bde4907921
|
4
|
+
data.tar.gz: e126ad5ff94b137c1bd983ea64b438dd60129aff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e34e2384e4d185ef4c6063892c18799d82d2b5e8825090d16c843d34e0b33f58e1b0641158e502252e5559226d206480b21027dc25ef41a37a64143ae45ba35
|
7
|
+
data.tar.gz: 0db3ef7390c70efd6cc77cb147a0147273caafe9ef0d905866dbd3b8981dd923d7bc25305d5d54bde87318d1a6e424be63559631e5e22efa1134340018d9280a
|
data/lib/file_pool.rb
CHANGED
@@ -26,13 +26,33 @@ module FilePool
|
|
26
26
|
# * :encryption_block_size (Integer) sets the block size for
|
27
27
|
# encryption/decryption in bytes. Larger blocks need more memory and less time (less IO).
|
28
28
|
# Defaults to 1'048'576 (1 MiB).
|
29
|
+
# * :copy_source (true,false)
|
30
|
+
# if +false+ files added to the pool are hard-linked with the source if source and file pool
|
31
|
+
# are on the same file system (default). If set to +true+ files are always copied into the pool.
|
32
|
+
# * :mode (Integer)
|
33
|
+
# File mode to set on all files added to the pool. E.g. +mode:+ +0640+ for +rw-r-----+ or symbolic "u=wrx,go=rx"
|
34
|
+
# (see Ruby stdlib FileUtils#chmod).
|
35
|
+
# Note that the desired mode is not set if the file is hard-linked with the source.
|
36
|
+
# Use +copy_source:true+ when to ensure.
|
37
|
+
# * :owner
|
38
|
+
# Owner of the files added to the pool.
|
39
|
+
# Note that the desired owner is not set if the file is hard-linked with the source.
|
40
|
+
# Use +copy_source:true+ when to ensure.
|
41
|
+
# * :group
|
42
|
+
# Group of the files added to the pool.
|
43
|
+
# Note that the desired group is not set if the file is hard-linked with the source.
|
44
|
+
# Use +copy_source:true+ when to ensure.
|
29
45
|
def self.setup root, options={}
|
30
|
-
unless(unknown = options.keys - [:encryption_block_size, :secrets_file]).empty?
|
46
|
+
unless(unknown = options.keys - [:encryption_block_size, :secrets_file, :copy_source, :mode, :owner, :group]).empty?
|
31
47
|
puts "FilePool Warning: unknown option(s) passed to #setup: #{unknown.inspect}"
|
32
48
|
end
|
33
49
|
@@root = root
|
34
50
|
@@crypted_mode = false
|
35
51
|
@@block_size = options[:encryption_block_size] || (1024*1024)
|
52
|
+
@@copy_source = options[:copy_source] || false
|
53
|
+
@@mode = options[:mode]
|
54
|
+
@@group = options[:group]
|
55
|
+
@@owner = options[:owner]
|
36
56
|
configure options[:secrets_file]
|
37
57
|
end
|
38
58
|
|
@@ -64,13 +84,16 @@ module FilePool
|
|
64
84
|
else
|
65
85
|
FileUtils.mkpath(id2dir newid)
|
66
86
|
end
|
67
|
-
FileUtils.link(path, target)
|
68
87
|
|
69
|
-
|
88
|
+
if !@@copy_source and (File.stat(path).dev == File.stat(File.dirname(target)).dev)
|
89
|
+
FileUtils.link(path, target)
|
90
|
+
else
|
91
|
+
FileUtils.copy(path, target)
|
92
|
+
FileUtils.chmod(@@mode, target) if @@mode
|
93
|
+
FileUtils.chown(@@owner, @@group, target)
|
94
|
+
end
|
70
95
|
|
71
|
-
|
72
|
-
FileUtils.copy(path, target)
|
73
|
-
return newid
|
96
|
+
newid
|
74
97
|
end
|
75
98
|
|
76
99
|
#
|
@@ -90,7 +113,7 @@ module FilePool
|
|
90
113
|
def self.add path
|
91
114
|
self.add!(path)
|
92
115
|
|
93
|
-
rescue Exception
|
116
|
+
rescue Exception
|
94
117
|
return false
|
95
118
|
end
|
96
119
|
|
data/lib/file_pool/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file_pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- robokopp (Robert Anniés)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uuidtools
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 2.1.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.1.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: |
|
28
42
|
FilePool helps to manage a large number of files in a Ruby
|
29
43
|
project. It takes care of the storage of files in a balanced directory
|
@@ -47,19 +61,18 @@ require_paths:
|
|
47
61
|
- lib
|
48
62
|
required_ruby_version: !ruby/object:Gem::Requirement
|
49
63
|
requirements:
|
50
|
-
- - ~>
|
64
|
+
- - "~>"
|
51
65
|
- !ruby/object:Gem::Version
|
52
66
|
version: '2.0'
|
53
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
68
|
requirements:
|
55
|
-
- -
|
69
|
+
- - ">="
|
56
70
|
- !ruby/object:Gem::Version
|
57
71
|
version: '0'
|
58
72
|
requirements: []
|
59
73
|
rubyforge_project:
|
60
|
-
rubygems_version: 2.
|
74
|
+
rubygems_version: 2.5.2
|
61
75
|
signing_key:
|
62
76
|
specification_version: 4
|
63
77
|
summary: Manage a large number files in a pool
|
64
78
|
test_files: []
|
65
|
-
has_rdoc:
|