datapimp 1.2.5 → 1.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5e7299d650179096768004980a3448474802f23
4
- data.tar.gz: ee170c2e5ac56f87ae4043b09b68be5ec7b80ab0
3
+ metadata.gz: 3e7609a425e96b824cd59702a741cf7c90c22feb
4
+ data.tar.gz: 019bd86145f9858406eca5b08ee8a7bafbe948c7
5
5
  SHA512:
6
- metadata.gz: 9e24d1d8012ba3b4e9b000a85d35d6427a712df310aa682fbc6ca7c7d7cbffaae9409f2f717330d719b305ba85d7131bc91dfddd1e1df1eaaac47e323a102ee3
7
- data.tar.gz: a91e94c7ed79af44d24becc338e46376b0b285ecd716146df98763c579a0d0ca857c2d2a39777efc48df637abbd3ad9bd9621c4703349823c7276563ef8ab744
6
+ metadata.gz: f3ec44528217a58b23251a886be555f16ae1533ead7c063d2d5fbb4d39a23c44639175f119a915ca0657e58af94ee6c30f8586ae39e9a221bb4a3967855b4894
7
+ data.tar.gz: 0071efb4dff0a298ef67a8a9dbbc510532a0094092c4e42bb75df42f2e0b50f57a2a614b3ab3827b24559209381376a1d7462713810f5db0328e46614667bbe7
@@ -21,13 +21,30 @@ module Datapimp
21
21
  end
22
22
 
23
23
  def run_pull_action
24
+ binding.pry
25
+
24
26
  remote_path_entries.each do |entry|
25
27
  remote_dropbox_path = entry.path
26
- remote_content = dropbox.download(remote_dropbox_path)
27
- relative_local_path = remote_dropbox_path.gsub("#{remote}/",'')
28
28
 
29
- log "Saving #{ remote_content.length } bytes to #{ relative_local_path }"
30
- local_path.join(relative_local_path).open("w+") {|fh| fh.write(remote_content) }
29
+ log "Syncing #{ remote_dropbox_path }"
30
+ begin
31
+ relative_local_path = remote_dropbox_path.gsub("#{remote}/",'')
32
+ target = local_path.join(relative_local_path)
33
+
34
+ next if target.exist? && target.size == entry.bytes
35
+
36
+ if entry.is_dir
37
+ log "Creating folder #{ relative_local_path }"
38
+ FileUtils.mkdir_p local_path.join(relative_local_path)
39
+ else
40
+ log "== Syncing #{ entry.path }"
41
+ remote_content = dropbox.download(remote_dropbox_path)
42
+ target.open("w+") {|fh| fh.write(remote_content) }
43
+ end
44
+ rescue => e
45
+ log "== Error while saving #{ remote_dropbox_path } to #{ relative_local_path }"
46
+ log " * Message: #{ e.message }"
47
+ end
31
48
  end
32
49
  end
33
50
 
@@ -93,13 +110,15 @@ module Datapimp
93
110
  end
94
111
 
95
112
  def remote_path_entries
96
- remote_path.map do |entry|
113
+ pather = lambda do |entry|
97
114
  if entry.is_dir
98
- dropbox.ls(entry.path)
115
+ Array(dropbox.ls(entry.path)).map(&pather)
99
116
  else
100
117
  entry
101
118
  end
102
- end.flatten
119
+ end
120
+
121
+ remote_path.map(&pather).flatten
103
122
  end
104
123
 
105
124
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datapimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Soeder