standard-file 0.2.5 → 0.2.6

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: b764c25dbf3350742c153673d75bbaceaac2c77e
4
- data.tar.gz: c2216bcc99380e629902a8530c6e29cb1c1de8ce
3
+ metadata.gz: 9aedc31c0aa95bb4a0ae123be4fb2586c907698d
4
+ data.tar.gz: 28ad97ff10532060e4b9ea501064c1f2d8bfaf0e
5
5
  SHA512:
6
- metadata.gz: 244e9829c182e952d0070ae349b0ccc7e2adfe721200a7290abfd6c0dc900d9cae472d179bb40c1c9e70a69b33b143f7cb9ee4babe679f02d167ec51ae507afc
7
- data.tar.gz: 02f1467f662af80b8b942cf69fef04656d51b68b199baa28296f46275b1063db02d01aa5fb631e97fa2b0a35ee911a1386412a08e1bea721efae1308b919ff64
6
+ metadata.gz: e88485ce13f7fe0b5c08994094b1173c336e5ca6f6cb92cd8b298fbc178befabbbf69647529b59720354bd24f437a88103d826073cfbbb397f9befe4b1a14542
7
+ data.tar.gz: c00e5e286926200e5505c42a9a2e8acb5cc9e979d764c38fc23aa478b16df86ff9589f5a4184d1c7c8565a40b795f0aafaed6ba8dc440d05e46e1c1236d6db6b
@@ -16,7 +16,7 @@ module StandardFile
16
16
  return @sync_fields || [:content, :enc_item_key, :content_type, :auth_hash, :deleted, :created_at]
17
17
  end
18
18
 
19
- def sync(item_hashes, options)
19
+ def sync(item_hashes, options, request)
20
20
 
21
21
  in_sync_token = options[:sync_token]
22
22
  in_cursor_token = options[:cursor_token]
@@ -24,7 +24,7 @@ module StandardFile
24
24
 
25
25
  retrieved_items, cursor_token = _sync_get(in_sync_token, in_cursor_token, limit).to_a
26
26
  last_updated = DateTime.now
27
- saved_items, unsaved_items = _sync_save(item_hashes)
27
+ saved_items, unsaved_items = _sync_save(item_hashes, request)
28
28
  if saved_items.length > 0
29
29
  last_updated = saved_items.sort_by{|m| m.updated_at}.last.updated_at
30
30
  end
@@ -48,6 +48,10 @@ module StandardFile
48
48
  # conflicts occur when you are trying to save an item for which there is a pending change already
49
49
  min_conflict_interval = 20
50
50
 
51
+ if Rails.env.development?
52
+ min_conflict_interval = 1
53
+ end
54
+
51
55
  saved_ids = saved_items.map{|x| x.uuid }
52
56
  retrieved_ids = retrieved_items.map{|x| x.uuid }
53
57
  conflicts = saved_ids & retrieved_ids # & is the intersection
@@ -66,6 +70,10 @@ module StandardFile
66
70
  })
67
71
 
68
72
  end
73
+
74
+ # We remove the item from retrieved items whether or not it satisfies the min_conflict_interval
75
+ # This is because the 'saved' value takes precedence, since that's the current value in the database.
76
+ # So by removing it from retrieved, we are forcing the client to ignore this change.
69
77
  retrieved_items.delete(conflicted)
70
78
  end
71
79
  end
@@ -97,7 +105,7 @@ module StandardFile
97
105
  return date
98
106
  end
99
107
 
100
- def _sync_save(item_hashes)
108
+ def _sync_save(item_hashes, request)
101
109
  if !item_hashes
102
110
  return [], []
103
111
  end
@@ -115,10 +123,12 @@ module StandardFile
115
123
  next
116
124
  end
117
125
 
126
+ item.last_user_agent = request.user_agent
118
127
  item.update(item_hash.permit(*permitted_params))
119
128
  # we want to force update the updated_at field, even if no changes were made
120
129
  # item.touch
121
130
 
131
+
122
132
  if item.deleted == true
123
133
  set_deleted(item)
124
134
  item.save
@@ -1,3 +1,3 @@
1
1
  module StandardFile
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard-file
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Standard File
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-08 00:00:00.000000000 Z
11
+ date: 2017-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails