file_pool 0.3.2 → 0.3.3

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.
@@ -1,4 +1,4 @@
1
1
  module FilePool
2
2
  # Version 0.3.2
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
4
4
  end
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
- return newid
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
- rescue Errno::EXDEV
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 => ex
116
+ rescue Exception
94
117
  return false
95
118
  end
96
119
 
@@ -292,6 +315,7 @@ module FilePool
292
315
  output = Tempfile.new 'FilePool-decrypt'
293
316
 
294
317
  buf = ''
318
+
295
319
  File.open(path) do |inf|
296
320
  while inf.read(@@block_size, buf)
297
321
  output << decipher.update(buf)
metadata CHANGED
@@ -1,65 +1,89 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: file_pool
3
- version: !ruby/object:Gem::Version
4
- version: 0.3.2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 3
10
+ version: 0.3.3
5
11
  platform: ruby
6
- authors:
7
- - robokopp (Robert Anniés)
12
+ authors:
13
+ - "robokopp (Robert Anni\xC3\xA9s)"
8
14
  autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
- date: 2017-02-02 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2018-03-23 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
14
22
  name: uuidtools
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: 2.1.2
20
- type: :runtime
21
23
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
24
27
  - - ~>
25
- - !ruby/object:Gem::Version
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 2
32
+ - 1
33
+ - 2
26
34
  version: 2.1.2
35
+ type: :runtime
36
+ version_requirements: *id001
27
37
  description: |
28
38
  FilePool helps to manage a large number of files in a Ruby
29
39
  project. It takes care of the storage of files in a balanced directory
30
40
  tree and generates unique identifiers for all files.
31
- email:
41
+
42
+ email:
32
43
  - robokopp@fernwerk.net
33
44
  executables: []
45
+
34
46
  extensions: []
35
- extra_rdoc_files:
36
- - README.md
37
- files:
47
+
48
+ extra_rdoc_files:
38
49
  - README.md
50
+ files:
39
51
  - lib/file_pool.rb
40
52
  - lib/file_pool/version.rb
53
+ - README.md
54
+ has_rdoc: true
41
55
  homepage: https://github.com/robokopp/file_pool
42
56
  licenses: []
43
- metadata: {}
57
+
44
58
  post_install_message:
45
59
  rdoc_options: []
46
- require_paths:
60
+
61
+ require_paths:
47
62
  - lib
48
- required_ruby_version: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - '>='
51
- - !ruby/object:Gem::Version
52
- version: '0'
53
- required_rubygems_version: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - '>='
56
- - !ruby/object:Gem::Version
57
- version: '0'
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
58
81
  requirements: []
82
+
59
83
  rubyforge_project:
60
- rubygems_version: 2.4.6
84
+ rubygems_version: 1.6.2
61
85
  signing_key:
62
- specification_version: 4
86
+ specification_version: 3
63
87
  summary: Manage a large number files in a pool
64
88
  test_files: []
65
- has_rdoc:
89
+
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 0bc512434b751b3cb4a8654b57ad512f389b9055
4
- data.tar.gz: 5e8b5fb1e8cb897cfa0b6b683cc40498c2033cc3
5
- SHA512:
6
- metadata.gz: 4ca7a96294fd39d864a9b6440875246edc0369de448ff61dbf9c0e1d2615718d09c99da1cfe0a4a31ca1477a5d637538545cbd811063e0ad039b4f95ff50392a
7
- data.tar.gz: 3e6666cabf58d6414e5b844462d7c6034b7adcb3c97942159d97fe7e0bfb329870d50a7a0317bd8c4c565cbee1071e681d238796eb00847a41c481909f82628b