dbox 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -146,10 +146,10 @@ Oh, Hello
146
146
  Using dbox from Ruby
147
147
  --------------------
148
148
 
149
- The Ruby clone, pull, and push APIs return a hash listing the changes made during that pull/push.
149
+ The Ruby clone, pull, and push APIs return a hash listing the changes made during that pull/push. If any failures were encountered while uploading or downloading from Dropbox, they will be shown in the ```:failed``` entry in the hash. Often, trying your operation again will resolve the failures as the Dropbox API returns errors for valid operations on occasion.
150
150
 
151
151
  ```ruby
152
- { :created => ["foo.txt"], :deleted => [], :updated => [] }
152
+ { :created => ["foo.txt"], :deleted => [], :updated => [], :failed => [] }
153
153
  ```
154
154
 
155
155
  ### Usage
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
data/bin/dbox CHANGED
@@ -51,12 +51,14 @@ when "create", "clone"
51
51
  # the same name of the directory being created/cloned
52
52
  local_path = args[1] || remote_path.split("/").last
53
53
 
54
- Dbox.send(command, remote_path, local_path)
54
+ res = Dbox.send(command, remote_path, local_path)
55
+ exit 1 if res[:failed].size > 0
55
56
  when "pull", "push"
56
57
  # default to current directory
57
58
  local_path = args[0] || "."
58
59
 
59
- Dbox.send(command, local_path)
60
+ res = Dbox.send(command, local_path)
61
+ exit 1 if res[:failed].size > 0
60
62
  when "move"
61
63
  remote_path = args[0]
62
64
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "dbox"
8
- s.version = "0.5.2"
8
+ s.version = "0.5.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ken Pratt"]
12
- s.date = "2011-10-03"
12
+ s.date = "2011-11-04"
13
13
  s.description = "An easy-to-use Dropbox client with fine-grained control over syncs."
14
14
  s.email = "ken@kenpratt.net"
15
15
  s.executables = ["dbox"]
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
49
49
  s.homepage = "http://github.com/kenpratt/dbox"
50
50
  s.licenses = ["MIT"]
51
51
  s.require_paths = ["lib"]
52
- s.rubygems_version = "1.8.10"
52
+ s.rubygems_version = "1.8.11"
53
53
  s.summary = "Dropbox made easy."
54
54
 
55
55
  if s.respond_to? :specification_version then
@@ -146,6 +146,11 @@ module Dbox
146
146
  insert_entry(:path => path, :is_dir => is_dir, :parent_id => parent_id, :modified => modified, :revision => revision, :hash => hash)
147
147
  end
148
148
 
149
+ def update_entry_by_id(id, fields)
150
+ raise(ArgumentError, "id cannot be null") unless id
151
+ update_entry(["WHERE id=?", id], fields)
152
+ end
153
+
149
154
  def update_entry_by_path(path, fields)
150
155
  raise(ArgumentError, "path cannot be null") unless path
151
156
  update_entry(["WHERE path=?", path], fields)
@@ -213,7 +213,8 @@ module Dbox
213
213
  dir = database.root_dir
214
214
  changes = calculate_changes(dir)
215
215
  log.debug "Executing changes:\n" + changes.map {|c| c.inspect }.join("\n")
216
- changelist = { :created => [], :deleted => [], :updated => [] }
216
+ parent_ids_of_failed_entries = []
217
+ changelist = { :created => [], :deleted => [], :updated => [], :failed => [] }
217
218
 
218
219
  # spin up a parallel task queue
219
220
  ptasks = ParallelTasks.new(MAX_PARALLEL_DBOX_OPS - 1) { clone_api_into_current_thread() }
@@ -237,6 +238,8 @@ module Dbox
237
238
  changelist[:created] << c[:path]
238
239
  rescue Dbox::ServerError => e
239
240
  log.error "Error while downloading #{c[:path]}: #{e.inspect}"
241
+ parent_ids_of_failed_entries << c[:parent_id]
242
+ changelist[:failed] << { :operation => :create, :path => c[:path], :error => e }
240
243
  end
241
244
  end
242
245
  end
@@ -253,6 +256,8 @@ module Dbox
253
256
  changelist[:updated] << c[:path]
254
257
  rescue Dbox::ServerError => e
255
258
  log.error "Error while downloading #{c[:path]}: #{e.inspect}"
259
+ parent_ids_of_failed_entries << c[:parent_id]
260
+ changelist[:failed] << { :operation => :create, :path => c[:path], :error => e }
256
261
  end
257
262
  end
258
263
  end
@@ -268,6 +273,12 @@ module Dbox
268
273
  # wait for operations to finish
269
274
  ptasks.finish
270
275
 
276
+ # clear hashes on any dirs with children that failed so that
277
+ # they are processed again on next pull
278
+ parent_ids_of_failed_entries.uniq.each do |id|
279
+ database.update_entry_by_id(id, :hash => nil)
280
+ end
281
+
271
282
  # sort & return output
272
283
  changelist.keys.each {|k| changelist[k].sort! }
273
284
  changelist
@@ -419,7 +430,7 @@ module Dbox
419
430
  dir = database.root_dir
420
431
  changes = calculate_changes(dir)
421
432
  log.debug "Executing changes:\n" + changes.map {|c| c.inspect }.join("\n")
422
- changelist = { :created => [], :deleted => [], :updated => [] }
433
+ changelist = { :created => [], :deleted => [], :updated => [], :failed => [] }
423
434
 
424
435
  # spin up a parallel task queue
425
436
  ptasks = ParallelTasks.new(MAX_PARALLEL_DBOX_OPS - 1) { clone_api_into_current_thread() }
@@ -431,24 +442,23 @@ module Dbox
431
442
  c[:parent_id] ||= lookup_id_by_path(c[:parent_path])
432
443
 
433
444
  if c[:is_dir]
434
- database.add_entry(c[:path], true, c[:parent_id], nil, nil, nil)
435
-
436
445
  # directory creation cannot go in a thread, since later
437
446
  # operations might depend on the directory being there
438
447
  create_dir(c)
448
+ database.add_entry(c[:path], true, c[:parent_id], nil, nil, nil)
439
449
  force_metadata_update_from_server(c)
440
450
  changelist[:created] << c[:path]
441
451
  else
442
- database.add_entry(c[:path], false, c[:parent_id], nil, nil, nil)
443
-
444
452
  # spin up a thread to upload the file
445
453
  ptasks.add do
446
454
  begin
447
455
  upload_file(c)
456
+ database.add_entry(c[:path], false, c[:parent_id], nil, nil, nil)
448
457
  force_metadata_update_from_server(c)
449
458
  changelist[:created] << c[:path]
450
459
  rescue Dbox::ServerError => e
451
460
  log.error "Error while uploading #{c[:path]}: #{e.inspect}"
461
+ changelist[:failed] << { :operation => :create, :path => c[:path], :error => e }
452
462
  end
453
463
  end
454
464
  end
@@ -469,6 +479,7 @@ module Dbox
469
479
  changelist[:updated] << c[:path]
470
480
  rescue Dbox::ServerError => e
471
481
  log.error "Error while uploading #{c[:path]}: #{e.inspect}"
482
+ changelist[:failed] << { :operation => :update, :path => c[:path], :error => e }
472
483
  end
473
484
  end
474
485
  end
@@ -487,8 +498,9 @@ module Dbox
487
498
  end
488
499
  database.delete_entry_by_path(c[:path])
489
500
  changelist[:deleted] << c[:path]
490
- rescue Dbox::ServerError
501
+ rescue Dbox::ServerError => e
491
502
  log.error "Error while deleting #{c[:path]}: #{e.inspect}"
503
+ changelist[:failed] << { :operation => :delete, :path => c[:path], :error => e }
492
504
  end
493
505
  end
494
506
  else
@@ -22,12 +22,12 @@ describe Dbox do
22
22
 
23
23
  describe "#create" do
24
24
  it "creates the local directory" do
25
- Dbox.create(@remote, @local).should eql(:created => [], :deleted => [], :updated => [""])
25
+ Dbox.create(@remote, @local).should eql(:created => [], :deleted => [], :updated => [""], :failed => [])
26
26
  @local.should exist
27
27
  end
28
28
 
29
29
  it "creates the remote directory" do
30
- Dbox.create(@remote, @local).should eql(:created => [], :deleted => [], :updated => [""])
30
+ Dbox.create(@remote, @local).should eql(:created => [], :deleted => [], :updated => [""], :failed => [])
31
31
  ensure_remote_exists(@remote)
32
32
  end
33
33
 
@@ -44,7 +44,7 @@ describe Dbox do
44
44
  Dbox.create(@remote, @local)
45
45
  rm_rf @local
46
46
  @local.should_not exist
47
- Dbox.clone(@remote, @local).should eql(:created => [], :deleted => [], :updated => [""])
47
+ Dbox.clone(@remote, @local).should eql(:created => [], :deleted => [], :updated => [""], :failed => [])
48
48
  @local.should exist
49
49
  end
50
50
 
@@ -68,7 +68,7 @@ describe Dbox do
68
68
 
69
69
  it "should be able to pull" do
70
70
  Dbox.create(@remote, @local)
71
- Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [])
71
+ Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [], :failed => [])
72
72
  end
73
73
 
74
74
  it "should be able to pull changes" do
@@ -77,19 +77,19 @@ describe Dbox do
77
77
 
78
78
  @alternate = "#{ALTERNATE_LOCAL_TEST_PATH}/#{@name}"
79
79
  Dbox.clone(@remote, @alternate)
80
- touch "#{@alternate}/hello.txt"
81
- Dbox.push(@alternate).should eql(:created => ["hello.txt"], :deleted => [], :updated => [])
80
+ make_file "#{@alternate}/hello.txt"
81
+ Dbox.push(@alternate).should eql(:created => ["hello.txt"], :deleted => [], :updated => [], :failed => [])
82
82
 
83
- Dbox.pull(@local).should eql(:created => ["hello.txt"], :deleted => [], :updated => [""])
83
+ Dbox.pull(@local).should eql(:created => ["hello.txt"], :deleted => [], :updated => [""], :failed => [])
84
84
  "#{@local}/hello.txt".should exist
85
85
  end
86
86
 
87
87
  it "should be able to pull after deleting a file and not have the file re-created" do
88
88
  Dbox.create(@remote, @local)
89
- touch "#{@local}/hello.txt"
90
- Dbox.push(@local).should eql(:created => ["hello.txt"], :deleted => [], :updated => [])
89
+ make_file "#{@local}/hello.txt"
90
+ Dbox.push(@local).should eql(:created => ["hello.txt"], :deleted => [], :updated => [], :failed => [])
91
91
  rm "#{@local}/hello.txt"
92
- Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [""])
92
+ Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [""], :failed => [])
93
93
  "#{@local}/hello.txt".should_not exist
94
94
  end
95
95
 
@@ -99,28 +99,28 @@ describe Dbox do
99
99
  @alternate = "#{ALTERNATE_LOCAL_TEST_PATH}/#{@name}"
100
100
  Dbox.clone(@remote, @alternate)
101
101
 
102
- Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [])
102
+ Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [], :failed => [])
103
103
 
104
- touch "#{@alternate}/foo.txt"
105
- touch "#{@alternate}/bar.txt"
106
- touch "#{@alternate}/baz.txt"
107
- Dbox.push(@alternate).should eql(:created => ["bar.txt", "baz.txt", "foo.txt"], :deleted => [], :updated => [])
108
- Dbox.pull(@alternate).should eql(:created => [], :deleted => [], :updated => [""])
109
- Dbox.pull(@alternate).should eql(:created => [], :deleted => [], :updated => [])
104
+ make_file "#{@alternate}/foo.txt"
105
+ make_file "#{@alternate}/bar.txt"
106
+ make_file "#{@alternate}/baz.txt"
107
+ Dbox.push(@alternate).should eql(:created => ["bar.txt", "baz.txt", "foo.txt"], :deleted => [], :updated => [], :failed => [])
108
+ Dbox.pull(@alternate).should eql(:created => [], :deleted => [], :updated => [""], :failed => [])
109
+ Dbox.pull(@alternate).should eql(:created => [], :deleted => [], :updated => [], :failed => [])
110
110
 
111
- Dbox.pull(@local).should eql(:created => ["bar.txt", "baz.txt", "foo.txt"], :deleted => [], :updated => [""])
112
- Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [])
111
+ Dbox.pull(@local).should eql(:created => ["bar.txt", "baz.txt", "foo.txt"], :deleted => [], :updated => [""], :failed => [])
112
+ Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [], :failed => [])
113
113
 
114
114
  mkdir "#{@alternate}/subdir"
115
- touch "#{@alternate}/subdir/one.txt"
115
+ make_file "#{@alternate}/subdir/one.txt"
116
116
  rm "#{@alternate}/foo.txt"
117
- File.open("#{@alternate}/baz.txt", "w") {|f| f << "baaz" }
118
- Dbox.push(@alternate).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => ["foo.txt"], :updated => ["baz.txt"])
119
- Dbox.pull(@alternate).should eql(:created => [], :deleted => [], :updated => ["", "subdir"])
120
- Dbox.pull(@alternate).should eql(:created => [], :deleted => [], :updated => [])
117
+ make_file "#{@alternate}/baz.txt"
118
+ Dbox.push(@alternate).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => ["foo.txt"], :updated => ["baz.txt"], :failed => [])
119
+ Dbox.pull(@alternate).should eql(:created => [], :deleted => [], :updated => ["", "subdir"], :failed => [])
120
+ Dbox.pull(@alternate).should eql(:created => [], :deleted => [], :updated => [], :failed => [])
121
121
 
122
- Dbox.pull(@local).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => ["foo.txt"], :updated => ["", "baz.txt"])
123
- Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [])
122
+ Dbox.pull(@local).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => ["foo.txt"], :updated => ["", "baz.txt"], :failed => [])
123
+ Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [], :failed => [])
124
124
  end
125
125
  end
126
126
 
@@ -131,102 +131,104 @@ describe Dbox do
131
131
 
132
132
  it "should be able to push" do
133
133
  Dbox.create(@remote, @local)
134
- Dbox.push(@local).should eql(:created => [], :deleted => [], :updated => [])
134
+ Dbox.push(@local).should eql(:created => [], :deleted => [], :updated => [], :failed => [])
135
135
  end
136
136
 
137
137
  it "should be able to push a new file" do
138
138
  Dbox.create(@remote, @local)
139
- touch "#{@local}/foo.txt"
140
- Dbox.push(@local).should eql(:created => ["foo.txt"], :deleted => [], :updated => [])
139
+ make_file "#{@local}/foo.txt"
140
+ Dbox.push(@local).should eql(:created => ["foo.txt"], :deleted => [], :updated => [], :failed => [])
141
141
  end
142
142
 
143
143
  it "should be able to push a new dir" do
144
144
  Dbox.create(@remote, @local)
145
145
  mkdir "#{@local}/subdir"
146
- Dbox.push(@local).should eql(:created => ["subdir"], :deleted => [], :updated => [])
146
+ Dbox.push(@local).should eql(:created => ["subdir"], :deleted => [], :updated => [], :failed => [])
147
147
  end
148
148
 
149
149
  it "should be able to push a new dir with a file in it" do
150
150
  Dbox.create(@remote, @local)
151
151
  mkdir "#{@local}/subdir"
152
- touch "#{@local}/subdir/foo.txt"
153
- Dbox.push(@local).should eql(:created => ["subdir", "subdir/foo.txt"], :deleted => [], :updated => [])
152
+ make_file "#{@local}/subdir/foo.txt"
153
+ Dbox.push(@local).should eql(:created => ["subdir", "subdir/foo.txt"], :deleted => [], :updated => [], :failed => [])
154
154
  end
155
155
 
156
156
  it "should be able to push a new file in an existing dir" do
157
157
  Dbox.create(@remote, @local)
158
158
  mkdir "#{@local}/subdir"
159
159
  Dbox.push(@local)
160
- touch "#{@local}/subdir/foo.txt"
161
- Dbox.push(@local).should eql(:created => ["subdir/foo.txt"], :deleted => [], :updated => [])
160
+ make_file "#{@local}/subdir/foo.txt"
161
+ Dbox.push(@local).should eql(:created => ["subdir/foo.txt"], :deleted => [], :updated => [], :failed => [])
162
162
  end
163
163
 
164
164
  it "should create the remote dir if it is missing" do
165
165
  Dbox.create(@remote, @local)
166
- touch "#{@local}/foo.txt"
166
+ make_file "#{@local}/foo.txt"
167
167
  @new_name = randname()
168
168
  @new_remote = File.join(REMOTE_TEST_PATH, @new_name)
169
169
  db = Dbox::Database.load(@local)
170
170
  db.update_metadata(:remote_path => @new_remote)
171
- Dbox.push(@local).should eql(:created => ["foo.txt"], :deleted => [], :updated => [])
171
+ Dbox.push(@local).should eql(:created => ["foo.txt"], :deleted => [], :updated => [], :failed => [])
172
172
  end
173
173
 
174
174
  it "should not re-download the file after creating" do
175
175
  Dbox.create(@remote, @local)
176
- touch "#{@local}/foo.txt"
177
- Dbox.push(@local).should eql(:created => ["foo.txt"], :deleted => [], :updated => [])
178
- Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [""])
176
+ make_file "#{@local}/foo.txt"
177
+ Dbox.push(@local).should eql(:created => ["foo.txt"], :deleted => [], :updated => [], :failed => [])
178
+ Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [""], :failed => [])
179
179
  end
180
180
 
181
181
  it "should not re-download the file after updating" do
182
182
  Dbox.create(@remote, @local)
183
- touch "#{@local}/foo.txt"
184
- Dbox.push(@local).should eql(:created => ["foo.txt"], :deleted => [], :updated => [])
185
- File.open("#{@local}/foo.txt", "w") {|f| f << "fooz" }
186
- Dbox.push(@local).should eql(:created => [], :deleted => [], :updated => ["foo.txt"])
187
- Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [""])
183
+ make_file "#{@local}/foo.txt"
184
+ Dbox.push(@local).should eql(:created => ["foo.txt"], :deleted => [], :updated => [], :failed => [])
185
+ sleep 1 # need to wait for timestamp to change before writing same file
186
+ make_file "#{@local}/foo.txt"
187
+ Dbox.push(@local).should eql(:created => [], :deleted => [], :updated => ["foo.txt"], :failed => [])
188
+ Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [""], :failed => [])
188
189
  end
189
190
 
190
191
  it "should not re-download the dir after creating" do
191
192
  Dbox.create(@remote, @local)
192
193
  mkdir "#{@local}/subdir"
193
- Dbox.push(@local).should eql(:created => ["subdir"], :deleted => [], :updated => [])
194
- Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [""])
194
+ Dbox.push(@local).should eql(:created => ["subdir"], :deleted => [], :updated => [], :failed => [])
195
+ Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [""], :failed => [])
195
196
  end
196
197
 
197
198
  it "should handle a complex set of changes" do
198
199
  Dbox.create(@remote, @local)
199
- touch "#{@local}/foo.txt"
200
- touch "#{@local}/bar.txt"
201
- touch "#{@local}/baz.txt"
202
- Dbox.push(@local).should eql(:created => ["bar.txt", "baz.txt", "foo.txt"], :deleted => [], :updated => [])
200
+ make_file "#{@local}/foo.txt"
201
+ make_file "#{@local}/bar.txt"
202
+ make_file "#{@local}/baz.txt"
203
+ Dbox.push(@local).should eql(:created => ["bar.txt", "baz.txt", "foo.txt"], :deleted => [], :updated => [], :failed => [])
204
+ sleep 1 # need to wait for timestamp to change before writing same file
203
205
  mkdir "#{@local}/subdir"
204
- touch "#{@local}/subdir/one.txt"
206
+ make_file "#{@local}/subdir/one.txt"
205
207
  rm "#{@local}/foo.txt"
206
- touch "#{@local}/baz.txt"
207
- Dbox.push(@local).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => ["foo.txt"], :updated => ["baz.txt"])
208
- Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => ["", "subdir"])
208
+ make_file "#{@local}/baz.txt"
209
+ Dbox.push(@local).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => ["foo.txt"], :updated => ["baz.txt"], :failed => [])
210
+ Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => ["", "subdir"], :failed => [])
209
211
  end
210
212
 
211
213
  it "should be able to handle crazy filenames" do
212
214
  Dbox.create(@remote, @local)
213
215
  crazy_name1 = '=+!@# $%^&*()[]{}<>_-|:?,\'~".txt'
214
216
  crazy_name2 = '[ˈdɔʏtʃ].txt'
215
- touch "#{@local}/#{crazy_name1}"
216
- touch "#{@local}/#{crazy_name2}"
217
- Dbox.push(@local).should eql(:created => [crazy_name1, crazy_name2], :deleted => [], :updated => [])
217
+ make_file "#{@local}/#{crazy_name1}"
218
+ make_file "#{@local}/#{crazy_name2}"
219
+ Dbox.push(@local).should eql(:created => [crazy_name1, crazy_name2], :deleted => [], :updated => [], :failed => [])
218
220
  rm_rf @local
219
- Dbox.clone(@remote, @local).should eql(:created => [crazy_name1, crazy_name2], :deleted => [], :updated => [""])
221
+ Dbox.clone(@remote, @local).should eql(:created => [crazy_name1, crazy_name2], :deleted => [], :updated => [""], :failed => [])
220
222
  end
221
223
 
222
224
  it "should be able to handle crazy directory names" do
223
225
  Dbox.create(@remote, @local)
224
226
  crazy_name1 = "Day[J] #42"
225
227
  mkdir File.join(@local, crazy_name1)
226
- touch File.join(@local, crazy_name1, "foo.txt")
227
- Dbox.push(@local).should eql(:created => [crazy_name1, File.join(crazy_name1, "foo.txt")], :deleted => [], :updated => [])
228
+ make_file File.join(@local, crazy_name1, "foo.txt")
229
+ Dbox.push(@local).should eql(:created => [crazy_name1, File.join(crazy_name1, "foo.txt")], :deleted => [], :updated => [], :failed => [])
228
230
  rm_rf @local
229
- Dbox.clone(@remote, @local).should eql(:created => [crazy_name1, File.join(crazy_name1, "foo.txt")], :deleted => [], :updated => [""])
231
+ Dbox.clone(@remote, @local).should eql(:created => [crazy_name1, File.join(crazy_name1, "foo.txt")], :deleted => [], :updated => [""], :failed => [])
230
232
  end
231
233
  end
232
234
 
@@ -280,24 +282,25 @@ describe Dbox do
280
282
  @alternate = "#{ALTERNATE_LOCAL_TEST_PATH}/#{@name}"
281
283
  Dbox.clone(@remote, @alternate)
282
284
 
283
- Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [])
285
+ Dbox.pull(@local).should eql(:created => [], :deleted => [], :updated => [], :failed => [])
284
286
 
285
287
  mkdir "#{@local}/subdir"
286
- touch "#{@local}/subdir/one.txt"
287
- Dbox.push(@local).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => [], :updated => [])
288
+ make_file "#{@local}/subdir/one.txt"
289
+ Dbox.push(@local).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => [], :updated => [], :failed => [])
288
290
 
289
- Dbox.pull(@alternate).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => [], :updated => [""])
291
+ Dbox.pull(@alternate).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => [], :updated => [""], :failed => [])
290
292
 
291
293
  rm_rf "#{@alternate}/subdir"
292
- Dbox.push(@alternate).should eql(:created => [], :deleted => ["subdir"], :updated => [])
294
+ Dbox.push(@alternate).should eql(:created => [], :deleted => ["subdir"], :updated => [], :failed => [])
293
295
 
294
- Dbox.pull(@local).should eql(:created => [], :deleted => ["subdir"], :updated => [""])
296
+ Dbox.pull(@local).should eql(:created => [], :deleted => ["subdir"], :updated => [""], :failed => [])
295
297
 
298
+ sleep 1 # need to wait for timestamp to change before writing same file
296
299
  mkdir "#{@local}/subdir"
297
- touch "#{@local}/subdir/one.txt"
298
- Dbox.push(@local).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => [], :updated => [])
300
+ make_file "#{@local}/subdir/one.txt"
301
+ Dbox.push(@local).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => [], :updated => [], :failed => [])
299
302
 
300
- Dbox.pull(@alternate).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => [], :updated => [""])
303
+ Dbox.pull(@alternate).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => [], :updated => [""], :failed => [])
301
304
  end
302
305
  end
303
306
  end
@@ -36,6 +36,10 @@ def log
36
36
  LOGGER
37
37
  end
38
38
 
39
+ def make_file(filepath)
40
+ File.open(filepath, "w") {|f| f << randname }
41
+ end
42
+
39
43
  RSpec::Matchers.define :exist do
40
44
  match do |actual|
41
45
  File.exists?(actual) == true
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbox
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 2
10
- version: 0.5.2
9
+ - 3
10
+ version: 0.5.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ken Pratt
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-03 00:00:00 Z
18
+ date: 2011-11-04 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: multipart-post
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  requirements: []
164
164
 
165
165
  rubyforge_project:
166
- rubygems_version: 1.8.10
166
+ rubygems_version: 1.8.11
167
167
  signing_key:
168
168
  specification_version: 3
169
169
  summary: Dropbox made easy.