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 +4 -0
- data/VERSION +1 -1
- data/dbox.gemspec +1 -1
- data/lib/dbox/database.rb +16 -8
- metadata +3 -3
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.2
|
data/dbox.gemspec
CHANGED
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
|
-
|
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
|
-
|
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 #{
|
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 #{
|
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(
|
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