dbox 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.6.2 / 2011-11-24
2
+ * Bug Fixes
3
+ * Fixed db migration.
4
+
1
5
  == 0.6.1 / 2011-11-24
2
6
  * Bug Fixes
3
7
  * Fixed sync command in command-line client.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.6.2
data/dbox.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "dbox"
8
- s.version = "0.6.1"
8
+ s.version = "0.6.2"
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"]
data/lib/dbox/database.rb CHANGED
@@ -100,7 +100,7 @@ module Dbox
100
100
  new_revisions = {}
101
101
 
102
102
  # fetch the new revision IDs from dropbox
103
- find_entries().each do |entry|
103
+ find_entries_with_columns([ :id, :path, :is_dir, :parent_id, :hash, :modified, :revision ]).each do |entry|
104
104
  path = relative_to_remote_path(entry[:path])
105
105
  begin
106
106
  data = api.metadata(path, nil, false)
@@ -164,7 +164,7 @@ module Dbox
164
164
  })
165
165
 
166
166
  # calculate hashes on files with same timestamp as we have (as that was the previous mechanism used to check freshness)
167
- find_entries().each do |entry|
167
+ find_entries_with_columns([ :id, :path, :is_dir, :parent_id, :local_hash, :remote_hash, :modified, :revision ]).each do |entry|
168
168
  unless entry[:is_dir]
169
169
  path = relative_to_local_path(entry[:path])
170
170
  if times_equal?(File.mtime(path), entry[:modified])
@@ -283,18 +283,26 @@ module Dbox
283
283
  private
284
284
 
285
285
  def find_entry(conditions = "", *args)
286
+ find_entry_with_columns(ENTRY_COLS, conditions, *args)
287
+ end
288
+
289
+ def find_entry_with_columns(entry_cols, conditions = "", *args)
286
290
  res = @db.get_first_row(%{
287
- SELECT #{ENTRY_COLS.join(",")} FROM entries #{conditions} LIMIT 1;
291
+ SELECT #{entry_cols.join(",")} FROM entries #{conditions} LIMIT 1;
288
292
  }, *args)
289
- entry_res_to_fields(res)
293
+ entry_res_to_fields(entry_cols, res)
290
294
  end
291
295
 
292
296
  def find_entries(conditions = "", *args)
297
+ find_entries_with_columns(ENTRY_COLS, conditions, *args)
298
+ end
299
+
300
+ def find_entries_with_columns(entry_cols, conditions = "", *args)
293
301
  out = []
294
302
  @db.execute(%{
295
- SELECT #{ENTRY_COLS.join(",")} FROM entries #{conditions} ORDER BY path ASC;
303
+ SELECT #{entry_cols.join(",")} FROM entries #{conditions} ORDER BY path ASC;
296
304
  }, *args) do |res|
297
- out << entry_res_to_fields(res)
305
+ out << entry_res_to_fields(entry_cols, res)
298
306
  end
299
307
  out
300
308
  end
@@ -327,9 +335,9 @@ module Dbox
327
335
  }, *args)
328
336
  end
329
337
 
330
- def entry_res_to_fields(res)
338
+ def entry_res_to_fields(entry_cols, res)
331
339
  if res
332
- h = make_fields(ENTRY_COLS, res)
340
+ h = make_fields(entry_cols, res)
333
341
  h[:is_dir] = (h[:is_dir] == 1)
334
342
  h[:modified] = Time.at(h[:modified]) if h[:modified]
335
343
  h
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: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 1
10
- version: 0.6.1
9
+ - 2
10
+ version: 0.6.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ken Pratt