(self, req, resp, platform, buildquality, commitid)
| 12 | class 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 | |
| 50 | class VSCBinaryFromCommitId(object): |
| 51 |
nothing calls this directly
no test coverage detected