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

Method on_get

vscoffline/server.py:14–48  ·  view source on GitHub ↗
(self, req, resp, platform, buildquality, commitid)

Source from the content-addressed store, hash-verified

12class VSCUpdater(object):
13
14 def on_get(self, req, resp, platform, buildquality, commitid):
15 updatedir = os.path.join(vsc.ARTIFACTS_INSTALLERS, platform, buildquality)
16 if not os.path.exists(updatedir):
17 log.warning(f'Update build directory does not exist at {updatedir}. Check sync or sync configuration.')
18 resp.status = falcon.HTTP_500
19 return
20 latestpath = os.path.join(updatedir, 'latest.json')
21 latest = vsc.Utility.load_json(latestpath)
22 if not latest:
23 resp.content = 'Unable to load latest.json'
24 log.warning(f'Unable to load latest.json for platform {platform} and buildquality {buildquality}')
25 resp.status = falcon.HTTP_500
26 return
27 if latest['version'] == commitid:
28 # No update available
29 log.debug(f'Client {platform}, Quality {buildquality}. No Update available.')
30 resp.status = falcon.HTTP_204
31 return
32 name = latest['name']
33 updatepath = vsc.Utility.first_file(updatedir, f'vscode-{name}.*')
34 if not updatepath:
35 resp.content = 'Unable to find update payload'
36 log.warning(f'Unable to find update payload from {updatedir}/vscode-{name}.*')
37 resp.status = falcon.HTTP_404
38 return
39 if not vsc.Utility.hash_file_and_check(updatepath, latest['sha256hash']):
40 resp.content = 'Update payload hash mismatch'
41 log.warning(f'Update payload hash mismatch {updatepath}')
42 resp.status = falcon.HTTP_403
43 return
44 # Url to get update
45 latest['url'] = vsc.URLROOT + updatepath
46 log.debug(f'Client {platform}, Quality {buildquality}. Providing update {updatepath}')
47 resp.status = falcon.HTTP_200
48 resp.media = latest
49
50class VSCBinaryFromCommitId(object):
51

Callers

nothing calls this directly

Calls 3

load_jsonMethod · 0.80
first_fileMethod · 0.80
hash_file_and_checkMethod · 0.80

Tested by

no test coverage detected