def _get_and_update_info(self) -> Dict[str, Any]: info = raw.get_info(self.db) info_updates = dict( mod=int(time.time() * 1000), # Modification time stamp usn=-1, # Signals update needed ) if raw.get_db_version(self.db) == 0: for key in info_updates: assert key in info info.update(info_updates) elif raw.get_db_version(self.db) == 1: assert len(info) == 1 first_key = list(info)[0] info[first_key].update(info_updates) # fixme: this currently doesn't work. In the new db structure there's # a tags table instead of a field, but it doesn't seem to be # used. # if self.__items["notes"] is not None: # # missing_tags = list( # set(info["tags"].keys()) # - set(self.__items["notes"].list_tags()) # ) # for tag in missing_tags: # # I'm assuming that this is the usn (update sequence number) # # of the tags # info["tags"][tag] = -1 return info
def _get_and_update_info(self) -> Dict[str, Any]: info = raw.get_info(self.db) info["mod"] = int(time.time() * 1000) # Modification time stamp info["usn"] = -1 # Signals update needed if self.__items["notes"] is not None: missing_tags = list( set(info["tags"].keys()) - set(self.__items["notes"].list_tags()) ) for tag in missing_tags: # I'm assuming that this is the usn (update sequence number) # of the tags info["tags"][tag] = -1 return info
def test_set_get_inverse(self): info = get_info(self.db_read) set_info(self.db_write, info) info2 = get_info(self.db_write) self.assertDictEqual(info, info2)