Skip to content

Commit

Permalink
Fixing typescript build
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Jan 2, 2025
1 parent 5a7207d commit 4abe557
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 200 deletions.
13 changes: 10 additions & 3 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ export function decrypt(secret: string, value: string): string {
return result;
}

function takeBoolean(value: boolean | string): boolean {
if (value === 'true') {
return true;
}
return value === true;
}

/**
* Decode passwords in complex structures
*
Expand Down Expand Up @@ -366,13 +373,13 @@ export function initConfig(options: {
source: 'cifs',
mount: options.config.cifsMount,
advancedDelete: options.config.advancedDelete,
debugging: options.config.debugLevel,
debugging: takeBoolean(options.config.debugLevel),
fileDir: options.bashDir,
wakeOnLAN: options.config.wakeOnLAN,
wakeOnLAN: takeBoolean(options.config.wakeOnLAN),
macAd: options.config.macAd,
wolTime: options.config.wolWait,
wolPort: options.config.wolPort || 9,
wolExtra: options.config.wolExtra,
wolExtra: takeBoolean(options.config.wolExtra),
smb: options.config.smbType,
sudo: options.config.sudoMount,
cifsDomain: options.config.cifsDomain,
Expand Down
15 changes: 13 additions & 2 deletions lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export interface BackItUpConfigComplexCreator extends BackItUpConfigSimpleCreato
ownCron: boolean;
debugging: boolean;
everyXDays: number;
deleteBackupAfter: number; // delete old backupfiles after x days
deleteBackupAfter: number; // delete old backup files after x days

historyHTML: BackItUpConfigMessageSimple;
historyJSON: BackItUpConfigMessageSimple;
Expand Down Expand Up @@ -442,7 +442,7 @@ export interface BackItUpConfigComplexCreatorCCU extends BackItUpConfigComplexCr
}

export interface BackItUpConfigInternal {
iobroker: BackItUpConfigComplexCreator;
iobroker: BackItUpConfigComplexCreatorIoBroker;
ccu: BackItUpConfigComplexCreatorCCU;
}

Expand Down Expand Up @@ -742,3 +742,14 @@ export interface BackItUpAdapterOptions {
zigbee2mqttPath: string;
zigbeeEnabled: boolean;
}

export type BackItUpExecuteContext = {
fileNames: string[];
errors: Record<string, string>;
done: boolean[];
types: string[];
};

export interface BackItUpLog {

}
34 changes: 19 additions & 15 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let http;
let https;

let systemLang = 'de'; // system language
const backupConfig = {};
let backupConfig = {};
const backupTimeSchedules = []; // Array for Backup Times
let taskRunning = false;

Expand Down Expand Up @@ -65,7 +65,7 @@ function startAdapter(options) {

const type = id.split('.').pop();

if ((sysCheck && sysCheck.ready && sysCheck.ready === true) || adapter.config.cifsEnabled === true) {
if (sysCheck?.ready === true || adapter.config.cifsEnabled === true) {
let config;
try {
config = JSON.parse(JSON.stringify(backupConfig[type]));
Expand Down Expand Up @@ -1500,22 +1500,26 @@ async function main(adapter) {
}
}, 10000);

adapter.getForeignObject('system.config', (err, obj) => {
if (obj && obj.common && obj.common.language) {
systemLang = obj.common.language;
}
//initConfig(obj?.native?.secret || 'Zgfr56gFe87jJOM');
initConfig(adapter);
const systemConfig = await adapter.getForeignObjectAsync('system.config');
if (systemConfig?.common?.language) {
systemLang = systemConfig.common.language;
}
backupConfig = initConfig({
config: adapter.config,
systemLang,
bashDir,
secret: systemConfig?.native?.secret || 'Zgfr56gFe87jJOM',
log: adapter.log,
});

checkStates();
await checkStates();

if (adapter.config.hostType !== 'Slave') {
createBackupSchedule();
nextBackup(true, null);
if (adapter.config.hostType !== 'Slave') {
createBackupSchedule();
await nextBackup(true, null);

detectLatestBackupFile(adapter);
}
});
detectLatestBackupFile(adapter);
}

// subscribe on all variables of this adapter instance with pattern "adapterName.X.memory*"
adapter.subscribeStates('oneClick.*');
Expand Down
Loading

0 comments on commit 4abe557

Please sign in to comment.