MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / insert_cache

Method insert_cache

client/task/basic/localcache.py:49–86  ·  view source on GitHub ↗

向缓存文本中插入新的项目缓存数据 :param path_dict: 不同工具所需要的路径数量与内容不同,因此这里用json来存,运行数组和字典 path_dict的方式不在这里限制,使用处需要判断工具需要保存哪些增量数据

(self, path_dict)

Source from the content-addressed store, hash-verified

47 break
48
49 def insert_cache(self, path_dict):
50 """
51 向缓存文本中插入新的项目缓存数据
52 :param path_dict: 不同工具所需要的路径数量与内容不同,因此这里用json来存,运行数组和字典
53 path_dict的方式不在这里限制,使用处需要判断工具需要保存哪些增量数据
54 """
55 if not self.exist_file:
56 self.cache_data = []
57 if self.exist_cache:
58 for item in self.cache_data:
59 if item['scm_url'] == self.scm_url:
60 item['path_dict'] = path_dict
61 item['src_type'] = self.src_type
62 break
63 else:
64 self.cache_data.append(
65 {
66 'scm_url': self.scm_url,
67 'path_dict': path_dict,
68 'src_type': self.src_type
69 }
70 )
71 # cache中存在部分已经删除的缓存信息,需要进行清理
72 temp_set = []
73 for item in self.cache_data:
74 is_exists = True
75 for path in item['path_dict'].values():
76 if not os.path.exists(path):
77 is_exists = False
78 break
79 if is_exists:
80 temp_set.append(item)
81 self.cache_data = temp_set
82
83 text = json.dumps(self.cache_data, indent=2)
84 with open(self.cache_file, 'w') as cache_file:
85 cache_file.write(text)
86 cache_file.close()

Callers

nothing calls this directly

Calls 2

valuesMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected