def __apply_change(self, change_id, change_tuple): """Apply changes to our filesystem reported by GD. All we do is remove the current record components, if it's valid, and then reload it with what we were given. Note that since we don't necessarily know about the entries that have been changed, this also allows us to slowly increase our knowledge of the filesystem (of, obviously, only those things that change). """ (entry_id, was_deleted, entry) = change_tuple is_visible = entry.is_visible if entry else None self.__log.info("Applying change with change-ID (%d), entry-ID [%s], and " "is-visible of [%s]" % (change_id, entry_id, is_visible)) # First, remove any current knowledge from the system. self.__log.debug("Removing all trace of entry with ID [%s]." % (entry_id)) try: PathRelations.get_instance().remove_entry_all(entry_id) except: self.__log.exception("There was a problem remove entry with ID [%s] " "from the caches." % (entry_id)) raise # If it wasn't deleted, add it back. self.__log.debug("Registering changed entry with ID [%s]." % (entry_id)) if is_visible: path_relations = PathRelations.get_instance() try: path_relations.register_entry(entry) except: self.__log.exception("Could not register changed entry with ID " "[%s] with path-relations cache." % (entry_id)) raise
def test_get_about(self): return entry_id_1 = u'11EIs1ZxCykme0FnAdY8Xm_ktUCQ9y5lHC3EwAKFsiFk' entry1 = EntryCache.get_instance().cache.get(entry_id_1) # result = PathRelations.get_instance().register_entry(entry1) entry_id_2 = u'0AJFt2OXeDBqSUk9PVA' # entry2 = EntryCache.get_instance().cache.get(entry_id_2) # result = PathRelations.get_instance().register_entry(entry2) path_relations = PathRelations.get_instance() #print(len(entry.parents)) # path_relations.dump_ll() # print(AccountInfo().root_id) # path_relations.dump_entry_clause('0AJFt2OXeDBqSUk9PVA') # PathRelations.get_instance().dump_entry_clause('0B5Ft2OXeDBqSSmdIek1aajZtVDA') # return # entry_clause = path_relations.get_entry_clause_by_id(entry_id_1) #result = path_relations.find_path_components_goandget('/') result = path_relations.get_child_filenames_from_entry_id(entry_id_2) from pprint import pprint pprint(result) # result = EntryCache.get_instance().cache.get(u'11EIs1ZxCykme0FnAdY8Xm_ktUCQ9y5lHC3EwAKFsiFk') # result = EntryCache.get_instance().cache.get(u'11EIs1ZxCykme0FnAdY8Xm_ktUCQ9y5lHC3EwAKFsiFk') # result = EntryCache.get_instance().cache.get(u'11EIs1ZxCykme0FnAdY8Xm_ktUCQ9y5lHC3EwAKFsiFk') # result = EntryCache.get_instance().cache.get(u'11EIs1ZxCykme0FnAdY8Xm_ktUCQ9y5lHC3EwAKFsiFk') # print(result) return # result = AccountInfo().root_id #about = drive_proxy('get_about_info') # entries = drive_proxy('get_children_under_parent_id', parent_id=about.root_id) #entries = drive_proxy('get_parents_over_child_id', child_id=u'11EIs1ZxCykme0FnAdY8Xm_ktUCQ9y5lHC3EwAKFsiFk') # print(response[u'rootFolderId']) import pprint # pprint.pprint(response[u'importFormats']) pprint.pprint(result)
def test_remove_entry(self): return from gdrivefs.cache import PathRelations path_relations = PathRelations.get_instance() entry_clause = path_relations.get_clause_from_path('HelloFax') filenames = path_relations.get_child_filenames_from_entry_id( entry_clause[3]) root_id = u'0AJFt2OXeDBqSUk9PVA' middle_id = entry_clause[3] child_id = u'0B5Ft2OXeDBqSTmpjSHlVbEV5ajg' # from pprint import pprint # pprint(filenames) # path_relations.dump_entry_clause(middle_id) print("1: =============================") path_relations.dump_ll() print("2: =============================") # print("middle: %s" % (middle_id)) # return path_relations.remove_entry_recursive(middle_id) # path_relations.remove_entry(middle_id) print("3: =============================") path_relations.dump_ll() return try: path_relations.dump_entry_clause(root_id) except: print("<No root.>") try: path_relations.dump_entry_clause(middle_id) except: print("<No middle.>") try: path_relations.dump_entry_clause(child_id) except: print("<No child.>")
def test_remove_entry(self): return from gdrivefs.cache import PathRelations path_relations = PathRelations.get_instance() entry_clause = path_relations.get_clause_from_path('HelloFax') filenames = path_relations.get_child_filenames_from_entry_id(entry_clause[3]) root_id = u'0AJFt2OXeDBqSUk9PVA' middle_id = entry_clause[3] child_id = u'0B5Ft2OXeDBqSTmpjSHlVbEV5ajg' # from pprint import pprint # pprint(filenames) # path_relations.dump_entry_clause(middle_id) print("1: =============================") path_relations.dump_ll() print("2: =============================") # print("middle: %s" % (middle_id)) # return path_relations.remove_entry_recursive(middle_id) # path_relations.remove_entry(middle_id) print("3: =============================") path_relations.dump_ll() return try: path_relations.dump_entry_clause(root_id) except: print("<No root.>") try: path_relations.dump_entry_clause(middle_id) except: print("<No middle.>") try: path_relations.dump_entry_clause(child_id) except: print("<No child.>")