MCPcopy Create free account
hub / github.com/LOLINTERNETZ/vscodeoffline / update_state

Method update_state

vscoffline/server.py:113–157  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

111 self.update_worker.start()
112
113 def update_state(self):
114 # Load each extension
115 for extensiondir in glob.glob(vsc.ARTIFACTS_EXTENSIONS + '/*/'):
116
117 # Load the latest version of each extension
118 latestpath = os.path.join(extensiondir, 'latest.json')
119 latest = vsc.Utility.load_json(latestpath)
120
121 if not latest:
122 log.debug(f'Tried to load invalid manifest json {latestpath}')
123 continue
124
125 latest = self.process_loaded_extension(latest, extensiondir)
126
127 if not latest:
128 log.debug(f'Unable to determine latest version {latestpath}')
129 continue
130
131 # Determine the latest version
132 latestversion = latest['versions'][0]
133
134 # Find other versions
135 for versionpath in glob.glob(extensiondir + '/*/extension.json'):
136 #log.info(f'Version path: {versionpath}')
137 vers = vsc.Utility.load_json(versionpath)
138 if not vers:
139 log.debug(f'Tried to load invalid version manifest json {versionpath}')
140 continue
141 vers = self.process_loaded_extension(vers, extensiondir)
142
143 # If this extension.json is actually the latest version, then ignore it
144 if not vers or latestversion == vers['versions'][0]:
145 continue
146
147 # Append this other possible version
148 latest['versions'].append(vers['versions'][0])
149
150 # Sort versions
151 latest['versions'] = sorted(latest['versions'], key=lambda k: LooseVersion(k['version']), reverse=True)
152
153 # Save the extension in the cache
154 name = latest['identity']
155 self.extensions[name] = latest
156
157 log.info(f'Loaded {len(self.extensions)} extensions')
158
159 def process_loaded_extension(self, extension, extensiondir):
160 name = extension['identity']

Callers 2

update_state_loopMethod · 0.95
on_modifiedMethod · 0.80

Calls 2

load_jsonMethod · 0.80

Tested by

no test coverage detected