Skip to content

Commit 2202d94

Browse files
authored
[feat]: enriched logging on upload with version information (#2913)
* enriched logging on upload with version information * rm empty line
1 parent 9c7a6f5 commit 2202d94

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* (@foxriver76) extend the time to wait until controller is stopped on controller UI upgrade
1111
* (@foxriver76) improved backup/restore process to work for arbitrary large installations
1212
* (@GermanBluefox/@foxriver76) implemented automatic upload on adapter start if version mismatch is detected
13+
* (@foxriver76) enriched logging on upload with version information
1314

1415
## 6.0.11 (2024-08-21) - Kiera
1516
* (foxriver76) only generate `packageUpdates` notification, if new updates detected

packages/cli/src/lib/setup/setupUpload.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ export class Upload {
436436
const now = Date.now();
437437
if (now - this.lastProgressUpdate > 1_000) {
438438
this.lastProgressUpdate = now;
439-
await this.states.setStateAsync(uploadID, {
439+
await this.states.setState(uploadID, {
440440
val: Math.round((1_000 * (files.length - f)) / files.length) / 10,
441441
ack: true
442442
});
@@ -453,7 +453,7 @@ export class Upload {
453453

454454
// Set upload progress to 0;
455455
if (!isAdmin && files.length) {
456-
await this.states.setStateAsync(uploadID, { val: 0, ack: true });
456+
await this.states.setState(uploadID, { val: 0, ack: true });
457457
}
458458

459459
return adapter;
@@ -553,12 +553,12 @@ export class Upload {
553553
let obj;
554554
const uploadID = `system.adapter.${adapter}.upload`;
555555
try {
556-
obj = await this.objects.getObjectAsync(uploadID);
556+
obj = await this.objects.getObject(uploadID);
557557
} catch {
558558
// ignore
559559
}
560560
if (!obj) {
561-
await this.objects.setObjectAsync(uploadID, {
561+
await this.objects.setObject(uploadID, {
562562
_id: uploadID,
563563
type: 'state',
564564
common: {
@@ -722,7 +722,7 @@ export class Upload {
722722
if (res) {
723723
for (const row of res.rows) {
724724
if (row.value?.common.host === hostname) {
725-
const _obj = await this.objects.getObjectAsync(row.id);
725+
const _obj = await this.objects.getObject(row.id);
726726
const newObject = deepClone(_obj) as ioBroker.InstanceObject;
727727

728728
// TODO: refactor the following assignments into a method, where we can define which attributes need a real override and their defaults
@@ -822,9 +822,13 @@ export class Upload {
822822
}
823823
ioPackFile = null;
824824
}
825+
825826
ioPack = ioPack || ioPackFile;
826827

827828
if (ioPack) {
829+
logger.log(
830+
`Updating objects from io-package.json for adapter "${name}" with version "${ioPack.common.version}"`
831+
);
828832
// Always update installedFrom from File on disk if exists and set
829833
if (ioPackFile?.common?.installedFrom) {
830834
ioPack.common = ioPack.common || {};
@@ -869,8 +873,8 @@ export class Upload {
869873
obj.ts = Date.now();
870874

871875
try {
872-
await this.objects.setObjectAsync(`system.adapter.${name}`, obj);
873-
await this.objects.setObjectAsync(`system.host.${hostname}.adapter.${name}`, obj);
876+
await this.objects.setObject(`system.adapter.${name}`, obj);
877+
await this.objects.setObject(`system.host.${hostname}.adapter.${name}`, obj);
874878
} catch (e) {
875879
logger.error(
876880
`Cannot set "system.adapter.${name}" and "system.host.${hostname}.adapters.${name}": ${e.message}`

0 commit comments

Comments
 (0)