Skip to content

Commit

Permalink
Merge branch 'master' into issue-2543
Browse files Browse the repository at this point in the history
  • Loading branch information
foxriver76 authored Nov 28, 2023
2 parents c6f28e6 + 46aa2e4 commit eb51c07
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions packages/adapter/src/lib/adapter/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2189,7 +2189,7 @@ export class AdapterClass extends EventEmitter {
}
};

// if we were never ready, we don't trigger unload
// if we were never ready, we don't trigger the unload procedure
if (this.adapterReady) {
if (typeof this._options.unload === 'function') {
if (this._options.unload.length >= 1) {
Expand Down Expand Up @@ -2218,14 +2218,14 @@ export class AdapterClass extends EventEmitter {
}
}

// Even if the developer forgets to call the unload callback, we need to stop the process
// Therefore wait a short while and then force the unload
// Even if the developer forgets to call the unload callback, we need to stop the process.
// Therefore, wait a short while and then force the unload procedure
setTimeout(
() => {
if (this.#states) {
finishUnload();

// Give 1 seconds to write the value
// Give 1 second to write the value
setTimeout(() => {
if (!isPause) {
this._logger.info(`${this.namespaceLog} terminating with timeout`);
Expand All @@ -2245,7 +2245,7 @@ export class AdapterClass extends EventEmitter {
}

/**
* Reads the file certificate from given path and adds a file watcher to restart adapter on cert changes
* Reads the file certificate from a given path and adds a file watcher to restart adapter on cert changes
* if a cert is passed it is returned as it is
* @param cert
*/
Expand Down Expand Up @@ -2385,7 +2385,7 @@ export class AdapterClass extends EventEmitter {
const chained = this._readFileCertificate(obj.native.certificates[chainedName]).split(
'-----END CERTIFICATE-----\r\n'
);
// it is still file name and the file maybe does not exist, but we can omit this error
// it is still a file name, and the file maybe does not exist, but we can omit this error
if (chained.join('').length >= 512) {
const caArr = [];
for (const cert of chained) {
Expand Down Expand Up @@ -2426,7 +2426,7 @@ export class AdapterClass extends EventEmitter {
updateConfig(newConfig: Record<string, any>): ioBroker.SetObjectPromise;
/**
* Updates the adapter config with new values. Only a subset of the configuration has to be provided,
* since merging with the existing config is done automatically, e.g. like this:
* since merging with the existing config is done automatically, e.g., like this:
*
* `adapter.updateConfig({prop1: "newValue1"})`
*
Expand Down Expand Up @@ -2549,8 +2549,8 @@ export class AdapterClass extends EventEmitter {
// external signature
setTimeout(cb: TimeoutCallback, timeout: number, ...args: any[]): ioBroker.Timeout | undefined;
/**
* Same as setTimeout
* but it clears the running timers on unload
* Same as setTimeout,
* but it clears the running timers during the unload process
* does not work after unload has been called
*
* @param cb - timer callback
Expand Down Expand Up @@ -2638,7 +2638,7 @@ export class AdapterClass extends EventEmitter {

/**
* Same as setInterval
* but it clears the running intervals on unload
* but it clears the running intervals during the unload process
* does not work after unload has been called
*
* @param cb - interval callback
Expand Down Expand Up @@ -2696,7 +2696,7 @@ export class AdapterClass extends EventEmitter {
): Promise<void>;
setObject(id: string, obj: ioBroker.SettableObject, callback?: ioBroker.SetObjectCallback): Promise<void>;
/**
* Creates or overwrites object in objectDB.
* Creates or overwrites an object in objectDB.
*
* This function can create or overwrite objects in objectDB for this adapter.
* Only Ids that belong to this adapter can be modified. So the function automatically adds "adapter.X." to ID.
Expand Down Expand Up @@ -10450,17 +10450,26 @@ export class AdapterClass extends EventEmitter {
const obj = await this.getForeignObjectAsync('system.licenses');
const uuidObj = await this.getForeignObjectAsync('system.meta.uuid');
let uuid: string;
if (!uuidObj || !uuidObj.native || !uuidObj.native.uuid) {
if (!uuidObj?.native?.uuid) {
this._logger.warn(`${this.namespaceLog} No UUID found!`);
return licenses;
} else {
uuid = uuidObj.native.uuid;
}

if (obj && obj.native && obj.native.licenses && obj.native.licenses.length) {
if (obj?.native?.licenses?.length) {
const now = Date.now();
const cert = fs.readFileSync(path.join(__dirname, '..', '..', 'cert', 'cloudCert.crt'));
const version = semver.major(this.pack!.version);
let adapterObj: ioBroker.AdapterObject | null | undefined;
if (adapterName) {
try {
adapterObj = await this.getForeignObjectAsync(`system.adapter.${adapterName}`);
} catch {
// ignore
}
}

const version = semver.major(adapterObj?.common?.version || this.pack!.version);

obj.native.licenses.forEach((license: Record<string, any>) => {
try {
Expand Down

0 comments on commit eb51c07

Please sign in to comment.