From 60c021a44e6fdf69e2ca66274e7188c4aea3f268 Mon Sep 17 00:00:00 2001 From: jNullj <15849761+jNullj@users.noreply.github.com> Date: Fri, 22 Nov 2024 00:53:33 +0200 Subject: [PATCH 1/2] remove obsolete test for version without size changes upstream removed all null crate_size see also rust-lang/crates.io#9926 --- services/crates/crates-size.tester.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/services/crates/crates-size.tester.js b/services/crates/crates-size.tester.js index 6aea268ced66d..710ab99a35963 100644 --- a/services/crates/crates-size.tester.js +++ b/services/crates/crates-size.tester.js @@ -10,10 +10,6 @@ t.create('size (with version)') .get('/tokio/1.32.0.json') .expectBadge({ label: 'size', message: '725 kB' }) -t.create('size (with version where version doesnt have size)') - .get('/tokio/0.1.6.json') - .expectBadge({ label: 'crates.io', message: 'unknown' }) - t.create('size (not found)') .get('/not-a-crate.json') .expectBadge({ label: 'crates.io', message: 'not found' }) From 0c0b0b00b60f149c74ff6e88fc4c6a6e51e415b9 Mon Sep 17 00:00:00 2001 From: jNullj <15849761+jNullj@users.noreply.github.com> Date: Tue, 26 Nov 2024 22:55:31 +0200 Subject: [PATCH 2/2] remove null handling in CratesSize service --- services/crates/crates-base.js | 3 +-- services/crates/crates-size.service.js | 7 +------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/services/crates/crates-base.js b/services/crates/crates-base.js index 8d744ca5b6caa..307e828a08803 100644 --- a/services/crates/crates-base.js +++ b/services/crates/crates-base.js @@ -4,8 +4,7 @@ import { BaseJsonService, InvalidResponse } from '../index.js' const versionSchema = Joi.object({ downloads: nonNegativeInteger, - // Crate size is not available for all versions. - crate_size: nonNegativeInteger.allow(null), + crate_size: nonNegativeInteger, num: Joi.string().required(), license: Joi.string().required().allow(null), rust_version: Joi.string().allow(null), diff --git a/services/crates/crates-size.service.js b/services/crates/crates-size.service.js index ab819c46ac4ae..d5a58292e8c7d 100644 --- a/services/crates/crates-size.service.js +++ b/services/crates/crates-size.service.js @@ -1,5 +1,5 @@ import prettyBytes from 'pretty-bytes' -import { InvalidResponse, pathParams } from '../index.js' +import { pathParams } from '../index.js' import { BaseCratesService, description } from './crates-base.js' export default class CratesSize extends BaseCratesService { @@ -49,11 +49,6 @@ export default class CratesSize extends BaseCratesService { async handle({ crate, version }) { const json = await this.fetch({ crate, version }) const size = this.constructor.getVersionObj(json).crate_size - - if (size == null) { - throw new InvalidResponse({ prettyMessage: 'unknown' }) - } - return this.render({ size }) } }