MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / _sync_cached_record

Function _sync_cached_record

keepercommander/record_management.py:191–219  ·  view source on GitHub ↗

Fold a just-persisted record back into ``params.record_cache``. ``update_record`` reads the revision it puts on the wire from the cache, not from the passed-in record object, so leaving the cache at the pre-update revision makes a second update of the same record within one command fail

(params, record_uid, revision, client_modified_time,
                        encrypted_data, decrypted_data,
                        encrypted_extra=None, decrypted_extra=None, udata=None)

Source from the content-addressed store, hash-verified

189
190
191def _sync_cached_record(params, record_uid, revision, client_modified_time,
192 encrypted_data, decrypted_data,
193 encrypted_extra=None, decrypted_extra=None, udata=None):
194 # type: (KeeperParams, str, int, int, Optional[bytes], Optional[bytes], Optional[bytes], Optional[bytes], Optional[dict]) -> None
195 """Fold a just-persisted record back into ``params.record_cache``.
196
197 ``update_record`` reads the revision it puts on the wire from the cache, not
198 from the passed-in record object, so leaving the cache at the pre-update
199 revision makes a second update of the same record within one command fail
200 with ``RS_OUT_OF_SYNC``. The payload is written alongside the revision to keep
201 the entry self-consistent - ``KeeperRecord.load`` reads ``data_unencrypted``,
202 so a bumped revision paired with stale data would surface pre-update fields.
203 """
204 storage_record = params.record_cache.get(record_uid)
205 if not isinstance(storage_record, dict) or not revision:
206 return
207 storage_record['revision'] = revision
208 if client_modified_time:
209 storage_record['client_modified_time'] = client_modified_time
210 if encrypted_data is not None:
211 storage_record['data'] = utils.base64_url_encode(encrypted_data)
212 if decrypted_data is not None:
213 storage_record['data_unencrypted'] = decrypted_data
214 if encrypted_extra is not None:
215 storage_record['extra'] = utils.base64_url_encode(encrypted_extra)
216 if decrypted_extra is not None:
217 storage_record['extra_unencrypted'] = decrypted_extra
218 if udata is not None:
219 storage_record['udata'] = udata
220
221
222def update_record(params, record, skip_extra=False):

Callers 1

update_recordFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected