From 681cee67ba31945a1c5d663da318ace0adf8bff1 Mon Sep 17 00:00:00 2001 From: Blaise Osmalek Date: Mon, 8 Jun 2026 10:09:06 +0200 Subject: [PATCH] import fs module and update OTA check logic to compare version numbers correctly --- src/routes/sensorbox.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/routes/sensorbox.ts b/src/routes/sensorbox.ts index 690dff2..31a9b17 100644 --- a/src/routes/sensorbox.ts +++ b/src/routes/sensorbox.ts @@ -11,6 +11,7 @@ import { saveDevice, } from "../data"; import { generateDeviceToken, sensorboxAuth, verifyDeviceToken } from "../auth"; +import fs from "fs"; const router = express.Router(); @@ -119,15 +120,13 @@ router.get("/ota/check", sensorboxAuth, (req, res) => { saveDevice(device); const update = findLatestReleaseDb(device.type, group, hardwareVersion); - if (!update || update.version === softwareVersion) { + if (!update || update.version <= softwareVersion) { res.sendStatus(204); return; } const link = createDownloadLinkDb(device.id, update.id); const downloadUrl = `${config.baseUrl}/download/${link.id}`; - // Get size of the update file to include in the response header - const fs = require("fs"); let fileSize = 0; try { const stats = fs.statSync(update.filePath);