|
58 | 58 | if (!calculateThresholdInBytes(disk, diskInfo)) { |
59 | 59 | return Promise.reject(`Invalid configuration "${disk.threshold}" for disk "${disk.path}".`); |
60 | 60 | } |
| 61 | + disk.notificationTriggered = false; |
61 | 62 | verbose(`Disk "${disk.path}" threshold "${disk.threshold}", which is ${disk.thresholdInBytes} bytes.`); |
62 | 63 | } |
63 | 64 | checkDiskFreeSpace(disk, diskInfo); |
|
143 | 144 |
|
144 | 145 | function checkDiskFreeSpace(disk, diskInfo) { |
145 | 146 | if (diskInfo.free < disk.thresholdInBytes) { |
146 | | - if (settings.notificationTypes.find(type => type.toLowerCase() === NotificationType.Email)) { |
147 | | - warning(replaceMacro('Free space on disk {DISK} has dropped under {THRESHOLD}! Sending email notification...', disk, diskInfo)); |
148 | | - sendEmailNotification(disk, diskInfo); |
149 | | - } |
150 | | - if (settings.notificationTypes.find(type => type.toLowerCase() === NotificationType.Desktop)) { |
151 | | - warning(replaceMacro('Free space on disk {DISK} has dropped under {THRESHOLD}! Showing desktop notification...', disk, diskInfo)); |
152 | | - sendDesktopNotification(disk, diskInfo); |
| 147 | + if (!disk.notificationTriggered) { |
| 148 | + disk.notificationTriggered = true; |
| 149 | + if (settings.notificationTypes.find(type => type.toLowerCase() === NotificationType.Email)) { |
| 150 | + warning(replaceMacro('Free space on disk {DISK} has dropped under {THRESHOLD}! Sending email notification...', disk, diskInfo)); |
| 151 | + sendEmailNotification(disk, diskInfo); |
| 152 | + } |
| 153 | + if (settings.notificationTypes.find(type => type.toLowerCase() === NotificationType.Desktop)) { |
| 154 | + warning(replaceMacro('Free space on disk {DISK} has dropped under {THRESHOLD}! Showing desktop notification...', disk, diskInfo)); |
| 155 | + sendDesktopNotification(disk, diskInfo); |
| 156 | + } |
153 | 157 | } |
| 158 | + } else { |
| 159 | + disk.notificationTriggered = false; |
154 | 160 | } |
155 | 161 | } |
156 | 162 |
|
|
193 | 199 | notifier.notify({ |
194 | 200 | title: 'Low disk space warning', |
195 | 201 | message: replaceMacro('Free space on disk {DISK} has dropped under {THRESHOLD}!', disk, diskInfo), |
| 202 | + appID: 'Disk Space Monitor', |
196 | 203 | icon: getImagePath('low-disk-space.png'), |
197 | 204 | }); |
198 | 205 | } |
|
0 commit comments