Skip to content
This repository was archived by the owner on Feb 22, 2025. It is now read-only.

Commit d7a6476

Browse files
committed
Prevent high values from being used as tiers
1 parent 04bfa1b commit d7a6476

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/drivers/google-drive.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,11 @@ module.exports = async ({
127127
}
128128
// Store archives for processing
129129
// Archives might or might not be songs.
130-
// The 200 MB threshold is just mostly here to not kill my bandwidth with multi-GB packs, which are therefore excluded.
131-
// The good practice for such packs would be to rehost it (either by individual charters, or independently with separate
132-
// folders/archives for each song)
133-
// 2019-03-31: Increasing it to 500 MB to attempt taking modcharts/video backgrounds into account
130+
// 2021-03-31: I have no idea what I'm doing with file limits anymore
131+
const SIZE_LIMIT_MB = 69;
134132
if (
135133
['rar', 'zip', '7z'].indexOf(item.fileExtension) >= 0 &&
136-
item.size < 52428800 &&
134+
item.size < SIZE_LIMIT_MB * (1024 * 1024) &&
137135
item.webContentLink
138136
) {
139137
archives.push(item);

src/utils/db.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
const Pg = require('./pg');
2+
// https://cdn.discordapp.com/attachments/616706064053829633/826847468737527878/unknown.png
3+
// https://cdn.discordapp.com/attachments/616706064053829633/826845717069955082/unknown.png
4+
// programming, I love that drug
5+
const MAX_DIFF = 32000;
26

37
module.exports.getNbSongs = () =>
48
Pg.q`SELECT COUNT(*) AS "nbSongs" FROM "Songs"`.then(
@@ -235,15 +239,15 @@ module.exports.upsertSongs = async (songs, noUpdateLastModified) => {
235239
];
236240
return [
237241
...wordableFields,
238-
+diff_band >= 0 ? +diff_band >> 0 : null,
239-
+diff_guitar >= 0 ? +diff_guitar >> 0 : null,
240-
+diff_bass >= 0 ? +diff_bass >> 0 : null,
241-
+diff_rhythm >= 0 ? +diff_rhythm >> 0 : null,
242-
+diff_drums >= 0 ? +diff_drums >> 0 : null,
243-
+diff_vocals >= 0 ? +diff_vocals >> 0 : null,
244-
+diff_keys >= 0 ? +diff_keys >> 0 : null,
245-
+diff_guitarghl >= 0 ? +diff_guitarghl >> 0 : null,
246-
+diff_bassghl >= 0 ? +diff_bassghl >> 0 : null,
242+
+diff_band >= 0 ? Math.min(+diff_band, MAX_DIFF) >> 0 : null,
243+
+diff_guitar >= 0 ? Math.min(+diff_guitar, MAX_DIFF) >> 0 : null,
244+
+diff_bass >= 0 ? Math.min(+diff_bass, MAX_DIFF) >> 0 : null,
245+
+diff_rhythm >= 0 ? Math.min(+diff_rhythm, MAX_DIFF) >> 0 : null,
246+
+diff_drums >= 0 ? Math.min(+diff_drums, MAX_DIFF) >> 0 : null,
247+
+diff_vocals >= 0 ? Math.min(+diff_vocals, MAX_DIFF) >> 0 : null,
248+
+diff_keys >= 0 ? Math.min(+diff_keys, MAX_DIFF) >> 0 : null,
249+
+diff_guitarghl >= 0 ? Math.min(+diff_guitarghl, MAX_DIFF) >> 0 : null,
250+
+diff_bassghl >= 0 ? Math.min(+diff_bassghl, MAX_DIFF) >> 0 : null,
247251
diffs.guitar,
248252
diffs.bass,
249253
diffs.rhythm,

0 commit comments

Comments
 (0)