revert worker.js
parent
bfd724f1bd
commit
3323b19d85
48
worker.js
48
worker.js
|
@ -10,14 +10,25 @@ const { open } = require('sqlite');
|
|||
|
||||
const lockfile = require('proper-lockfile');
|
||||
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const bodyParser = require('body-parser');
|
||||
const cookieParser = require('cookie-parser');
|
||||
const jwt = require('jsonwebtoken');
|
||||
|
||||
const htmlspecialchars = require('htmlspecialchars');
|
||||
|
||||
const dirTree = require('directory-tree');
|
||||
const { resolve } = require('path');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
const Reader = require('@commaai/log_reader');
|
||||
var ffprobe = require('ffprobe'),
|
||||
ffprobeStatic = require('ffprobe-static');
|
||||
ffprobeStatic = require('ffprobe-static');
|
||||
const { exception } = require('console');
|
||||
|
||||
var db = null;
|
||||
|
||||
|
@ -54,7 +65,7 @@ function validateJWTToken(token, publicKey) {
|
|||
}
|
||||
|
||||
function formatDate(timestampMs) {
|
||||
return new Date(timestampMs).toISOString().replace(/T/, ' ').replace(/\..+/, '');
|
||||
return new Date(timestampMs).toISOString().replace(/T/, ' ').replace(/\..+/, '');
|
||||
}
|
||||
|
||||
function formatDuration(durationSeconds) {
|
||||
|
@ -116,12 +127,7 @@ function simpleStringify(object) {
|
|||
}
|
||||
simpleObject[prop] = object[prop];
|
||||
}
|
||||
if (typeof (object[prop]) === 'function') {
|
||||
continue;
|
||||
}
|
||||
simpleObject[prop] = object[prop];
|
||||
}
|
||||
return JSON.stringify(simpleObject); // returns cleaned up JSON
|
||||
return JSON.stringify(simpleObject); // returns cleaned up JSON
|
||||
}
|
||||
|
||||
function writeFileSync(path, buffer, permission) {
|
||||
|
@ -183,11 +189,6 @@ function deleteFolderRecursive(directoryPath) {
|
|||
});
|
||||
fs.rmdirSync(directoryPath);
|
||||
}
|
||||
logger.error('moveUploadedFile failed to writeFileSync');
|
||||
return false;
|
||||
}
|
||||
logger.error(`moveUploadedFile invalid final path, check permissions to create / write '${config.storagePath + directory}'`);
|
||||
return false;
|
||||
}
|
||||
|
||||
async function dbProtectedRun() {
|
||||
|
@ -207,9 +208,6 @@ async function dbProtectedRun() {
|
|||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, 1000));
|
||||
continue;
|
||||
}
|
||||
logger.error(`unable to complete dbProtectedRun for ${arguments}`);
|
||||
return null;
|
||||
|
@ -232,9 +230,6 @@ async function dbProtectedGet() {
|
|||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, 1000));
|
||||
continue;
|
||||
}
|
||||
logger.error(`unable to complete dbProtectedGet for ${arguments}`);
|
||||
return null;
|
||||
|
@ -257,9 +252,6 @@ async function dbProtectedAll() {
|
|||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, 1000));
|
||||
continue;
|
||||
}
|
||||
logger.error(`unable to complete dbProtectedGet for ${arguments}`);
|
||||
return null;
|
||||
|
@ -632,8 +624,6 @@ async function updateDrives() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var { filesize } = drive;
|
||||
if (uploadComplete) {
|
||||
|
@ -694,9 +684,8 @@ async function updateDrives() {
|
|||
fs.writeFileSync(`${drivePath}/qcamera.m3u8`, playlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateDevices();
|
||||
updateDevices();
|
||||
|
||||
setTimeout(() => {
|
||||
mainWorkerLoop();
|
||||
|
@ -718,7 +707,6 @@ async function deleteExpiredDrives() {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function removeDeletedDrivesPhysically() {
|
||||
|
@ -756,7 +744,6 @@ async function removeDeletedDrivesPhysically() {
|
|||
logger.error(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteOverQuotaDrives() {
|
||||
|
@ -794,7 +781,6 @@ async function deleteOverQuotaDrives() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteBootAndCrashLogs() {
|
||||
|
@ -829,8 +815,6 @@ async function deleteBootAndCrashLogs() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const crashlogDirectoryTree = dirTree(`${config.storagePath + device.dongle_id}/${dongleIdHash}/crash/`, { attributes: ['size'] });
|
||||
var crashlogFiles = [];
|
||||
|
@ -854,9 +838,7 @@ async function deleteBootAndCrashLogs() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function mainWorkerLoop() {
|
||||
|
|
Loading…
Reference in New Issue