migrate to "export default"

also, set no-use-before-define in linter
This commit is contained in:
Girish Ramakrishnan
2026-02-14 15:43:24 +01:00
parent ddb46646fa
commit 36aa641cb9
231 changed files with 2846 additions and 2728 deletions
+51 -50
View File
@@ -1,14 +1,14 @@
import assert from 'node:assert';
import BoxError from './boxerror.js';
import * as database from './database.js';
import database from './database.js';
import debugModule from 'debug';
import * as logs from './logs.js';
import logs from './logs.js';
import mysql from 'mysql2';
import path from 'node:path';
import paths from './paths.js';
import safe from 'safetydance';
import shellModule from './shell.js';
import * as _ from './underscore.js';
import _ from './underscore.js';
const debug = debugModule('box:tasks');
const shell = shellModule('tasks');
@@ -17,53 +17,6 @@ const ESTOPPED = 'stopped';
const ECRASHED = 'crashed';
const ETIMEOUT = 'timeout';
export default {
get,
add,
update,
setCompleted,
setCompletedByType,
list,
getLogs,
startTask,
stopTask,
stopAllTasks,
removePrivateFields,
_del: del,
// task types. if you add a task here, fill up the function table in taskworker and dashboard constants.js
// '_' prefix is removed for lookup
TASK_APP: 'app',
// "prefix" allows us to locate the tasks of a specific app or backup site
TASK_APP_BACKUP_PREFIX: 'appBackup_',
TASK_FULL_BACKUP_PREFIX: 'backup_', // full backup
TASK_CLEAN_BACKUPS_PREFIX: 'cleanBackups_',
TASK_BOX_UPDATE: 'boxUpdate',
TASK_CHECK_CERTS: 'checkCerts',
TASK_SYNC_DYNDNS: 'syncDyndns',
TASK_PREPARE_DASHBOARD_LOCATION: 'prepareDashboardLocation',
TASK_SYNC_EXTERNAL_LDAP: 'syncExternalLdap',
TASK_CHANGE_MAIL_LOCATION: 'changeMailLocation',
TASK_SYNC_DNS_RECORDS: 'syncDnsRecords',
TASK_CHECK_BACKUP_INTEGRITY: 'checkBackupIntegrity',
// error codes
ESTOPPED,
ECRASHED,
ETIMEOUT,
// testing
_TASK_IDENTITY: 'identity',
_TASK_CRASH: 'crash',
_TASK_ERROR: 'error',
_TASK_SLEEP: 'sleep'
};
let gTasks = {}; // holds AbortControllers indexed by task id
@@ -295,3 +248,51 @@ async function del(id) {
const result = await database.query('DELETE FROM tasks WHERE id = ?', [ id ]);
if (result.affectedRows !== 1) throw new BoxError(BoxError.NOT_FOUND, 'Task not found');
}
export default {
get,
add,
update,
setCompleted,
setCompletedByType,
list,
getLogs,
startTask,
stopTask,
stopAllTasks,
removePrivateFields,
_del: del,
// task types. if you add a task here, fill up the function table in taskworker and dashboard constants.js
// '_' prefix is removed for lookup
TASK_APP: 'app',
// "prefix" allows us to locate the tasks of a specific app or backup site
TASK_APP_BACKUP_PREFIX: 'appBackup_',
TASK_FULL_BACKUP_PREFIX: 'backup_', // full backup
TASK_CLEAN_BACKUPS_PREFIX: 'cleanBackups_',
TASK_BOX_UPDATE: 'boxUpdate',
TASK_CHECK_CERTS: 'checkCerts',
TASK_SYNC_DYNDNS: 'syncDyndns',
TASK_PREPARE_DASHBOARD_LOCATION: 'prepareDashboardLocation',
TASK_SYNC_EXTERNAL_LDAP: 'syncExternalLdap',
TASK_CHANGE_MAIL_LOCATION: 'changeMailLocation',
TASK_SYNC_DNS_RECORDS: 'syncDnsRecords',
TASK_CHECK_BACKUP_INTEGRITY: 'checkBackupIntegrity',
// error codes
ESTOPPED,
ECRASHED,
ETIMEOUT,
// testing
_TASK_IDENTITY: 'identity',
_TASK_CRASH: 'crash',
_TASK_ERROR: 'error',
_TASK_SLEEP: 'sleep'
};