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);