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

Method on_get

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

Source from the content-addressed store, hash-verified

50class VSCBinaryFromCommitId(object):
51
52 def on_get(self, req, resp, commitid, platform, buildquality):
53 updatedir = os.path.join(vsc.ARTIFACTS_INSTALLERS, platform, buildquality)
54 if not os.path.exists(updatedir):
55 log.warning(f'Update build directory does not exist at {updatedir}. Check sync or sync configuration.')
56 resp.status = falcon.HTTP_500
57 return
58 jsonpath = os.path.join(updatedir, f'{commitid}.json')
59 updatejson = vsc.Utility.load_json(jsonpath)
60 if not updatejson:
61 resp.content = f'Unable to load {jsonpath}'
62 log.warning(resp.content)
63 resp.status = falcon.HTTP_500
64 return
65 name = updatejson['name']
66 updatepath = vsc.Utility.first_file(updatedir, f'vscode-{name}.*')
67 if not updatepath:
68 resp.content = f'Unable to find update payload from {updatedir}/vscode-{name}.*'
69 log.warning(resp.content)
70 resp.status = falcon.HTTP_404
71 return
72 if not vsc.Utility.hash_file_and_check(updatepath, updatejson['sha256hash']):
73 resp.content = f'Update payload hash mismatch {updatepath}'
74 log.warning(resp.content)
75 resp.status = falcon.HTTP_403
76 return
77 # Url for the client to fetch the update
78 resp.set_header('Location', vsc.URLROOT + updatepath)
79 resp.status = falcon.HTTP_302
80
81class VSCRecommendations(object):
82

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