smart_s3_sync 0.0.12 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1767db822124a61f5d93e9b1bd028ef604ba68f9
4
- data.tar.gz: 198cfd1033178569ae744a95e2e39a73a7666927
3
+ metadata.gz: c8613330fab8c1fb442c003b4b87604c41ea2f4d
4
+ data.tar.gz: 098e63dde5e0c5e6f692299efca4e463cd75f1f3
5
5
  SHA512:
6
- metadata.gz: 2eabf0d9dc4cb0c6a5df75427599a8656d351c568989588a8642f3904ce047f23418f73c855e0403fb50e7ab174c8ba597a21089889181cb0536a051145ec8ac
7
- data.tar.gz: 4850ffdd09ac303a9018a6108e3a5d734a2a3114414ce771acfbd5a6f27d5e60d10a86b35419343609ba96db2fce3ff875aaa1c0903b51c6e150e15836eadea0
6
+ metadata.gz: 984ab151ebac3d4dcab6e1423c7ed165c97943daf9ec7f22b9c01d31360ef439fd578bfd2950a78c11a7e72c15f1ffda3a691ddeeb1f0096fbeb4f7afec73b60
7
+ data.tar.gz: 99fbae0099fa91e898dfa225e54fa1a158efbffb42216c9f0db750b175c6a3defab50244d53e9cade8e2e3f1bc9ecbd4035f27135af3d2ef5a2eeae8dae40ee1
@@ -13,17 +13,23 @@ module SmartS3Sync
13
13
  get(remote_dir, {:prefix => remote_prefix})
14
14
 
15
15
  # Add all files in the cloud to our map.
16
- print "Checking Files: 0"
16
+ $stderr.print "Checking Files: "
17
17
  checked = 0
18
18
  bucket.files.each do |file|
19
19
  table.push(file)
20
- print "\b" * checked.to_s.length
21
- print (checked += 1).to_s
20
+ if $stderr.tty?
21
+ $stderr.print "\b" * checked.to_s.length unless checked == 0
22
+ $stderr.print (checked += 1).to_s
23
+ elsif (checked += 1) == 1
24
+ $stderr.print '...'
25
+ elsif checked % 1000 == 0
26
+ $stderr.print '.'
27
+ end
22
28
  end
23
29
 
24
- puts "\n"
25
- puts "Status: Need to download #{table.to_download.length} files (#{table.to_download.map(&:size).inject(&:+)} bytes)"
26
- puts "Status: with an effective total of #{table.to_copy.inject(0){|coll, obj| coll + obj.destinations.length }} files (#{table.to_copy.map{|x| x.size * x.destinations.length }.inject(&:+)} bytes)"
30
+ $stderr.puts " done! (#{checked} files)\n"
31
+ $stderr.puts "Status: Need to download #{table.to_download.length} files (#{table.to_download.map(&:size).inject(&:+)} bytes)"
32
+ $stderr.puts "Status: with an effective total of #{table.to_copy.inject(0){|coll, obj| coll + obj.destinations.length }} files (#{table.to_copy.map{|x| x.size * x.destinations.length }.inject(&:+)} bytes)"
27
33
 
28
34
  # And copy them to the right places
29
35
  table.copy!(bucket)
@@ -31,14 +37,14 @@ module SmartS3Sync
31
37
  # sweep through and remove all files not in the cloud
32
38
  Dir[File.join(dir, '**/*')].each do |file|
33
39
  if !File.directory?(file)
34
- File.unlink(file) and puts "DELETING: #{file}" unless table.keep?(file)
40
+ File.unlink(file) and $stderr.puts "DELETING: #{file}" unless table.keep?(file)
35
41
  end
36
42
  end
37
43
 
38
44
  # and then all empty directories
39
45
  Dir[File.join(dir, '**/*')].each do |file|
40
46
  if File.directory?(file) && Dir.entries(file).length == 0
41
- puts "DELETING: #{file}"
47
+ $stderr.puts "DELETING: #{file}"
42
48
  Dir.rmdir(file)
43
49
  end
44
50
  end
@@ -42,7 +42,7 @@ module SmartS3Sync
42
42
  private
43
43
 
44
44
  def copy_from_fog(fog_dir)
45
- puts "Downloading #{remote_filename}"
45
+ $stderr.puts "Downloading #{remote_filename}"
46
46
  tries = 0
47
47
  file = nil
48
48
  begin
@@ -57,8 +57,8 @@ module SmartS3Sync
57
57
  rescue StandardError => e
58
58
  if tries < 5
59
59
  tries += 1
60
- puts e
61
- puts "retrying"
60
+ $stderr.puts e
61
+ $stderr.puts "retrying"
62
62
  retry
63
63
  else
64
64
  raise e
@@ -69,9 +69,9 @@ module SmartS3Sync
69
69
  end
70
70
 
71
71
  def copy_from_local(source)
72
- puts "Linking #{destinations.join(', ')}"
72
+ $stderr.puts "Linking #{destinations.join(', ')}"
73
73
  destinations.each do |dest|
74
- FileUtils.mkdir_p(File.dirname(dest))
74
+ FileUtils.mkdir_p(File.dirname(dest), :mode => 0755)
75
75
  FileUtils.ln(source, dest, :force => true)
76
76
  DigestCache.save_record(dest, File.mtime(dest).to_i, digest.to_s)
77
77
  end
@@ -101,6 +101,7 @@ module SmartS3Sync
101
101
  file.write chunk
102
102
  end
103
103
  file.close
104
+ File.chmod(0644, file.path)
104
105
  end
105
106
  end
106
107
  end
@@ -1,3 +1,3 @@
1
1
  module SmartS3Sync
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.14"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_s3_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Rhoden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3