Skip to content

Commit 5f45bcb

Browse files
authored
[feat]: only generate packageUpdates notification if a new package update has been detected (#2865)
* only generate packageUpdates notification if a new package update has been detected - closes #2864 * reuse const * remove unnecessary check * Update CHANGELOG.md Will be backported to Kiera * Update main.ts * Replace find by some
1 parent 67b3039 commit 5f45bcb

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
## __WORK IN PROGRESS__
55
-->
66

7-
## 6.0.10 (2024-08-05)
7+
## __WORK IN PROGRESS__ - Kiera
8+
* (@foxriver76) only generate `packageUpdates` notification, if new updates detected
9+
10+
## 6.0.10 (2024-08-05) - Kiera
811
* (foxriver76) fixed "alias subscription error" log
912
* (foxriver76) do not check for OS updates on Docker installations
1013
* (foxriver76) clear package update notification if no updates are present anymore

packages/controller/src/main.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5714,7 +5714,7 @@ async function setInstanceOfflineStates(id: ioBroker.ObjectIDs.Instance): Promis
57145714
* Check for updatable OS packages and register them as notification
57155715
*/
57165716
async function listUpdatableOsPackages(): Promise<void> {
5717-
if (tools.isDocker()) {
5717+
if (tools.isDocker() || !states) {
57185718
return;
57195719
}
57205720

@@ -5723,13 +5723,24 @@ async function listUpdatableOsPackages(): Promise<void> {
57235723

57245724
const packages = await packManager.listUpgradeablePackages();
57255725

5726+
const packageStateId = `${hostObjectPrefix}.osPackageUpdates`;
5727+
const packagesState = await states.getState(packageStateId);
5728+
5729+
await states.setState(packageStateId, { val: JSON.stringify(packages), ack: true });
5730+
57265731
if (!packages.length) {
57275732
await notificationHandler.clearNotifications('system', 'packageUpdates', `system.host.${hostname}`);
57285733
return;
57295734
}
57305735

5736+
const knownPackages: string[] = typeof packagesState?.val === 'string' ? JSON.parse(packagesState.val) : [];
5737+
const hasNewPackage = packages.some(pack => !knownPackages.includes(pack));
5738+
5739+
if (!hasNewPackage) {
5740+
return;
5741+
}
5742+
57315743
await notificationHandler.addMessage('system', 'packageUpdates', packages.join('\n'), `system.host.${hostname}`);
5732-
await states!.setState(`${hostObjectPrefix}.osPackageUpdates`, { val: JSON.stringify(packages), ack: true });
57335744
}
57345745

57355746
/**

0 commit comments

Comments
 (0)