Skip to content

Commit 89e73a7

Browse files
Fix: suppress ghost disk events (NaN / NaN undefined) in notifications (#256)
This prevents invalid “Found a new drive” notifications caused by leftover loop devices or zero-size/invalid disks. Changes: Added _isValidDiskEvent helper in CoreService.vue to validate incoming local-storage:disk:added events. Skip events with: size missing, "NaN", or 0. /dev/loop* devices that have no mount point. Invalid events are cleaned from the user DB via this.$api.users.delLetter(eventJson.uuid) so they don’t persist across reloads. Why: Several users reported seeing random “Found a new drive NaN / NaN undefined” popups in the UI. These come from orphaned loop devices or misdetected volumes. This patch hides those junk events while preserving normal drive management (real disks and mounted loops still work as expected). Impact: End users no longer see phantom drive popups. No backend or DB schema changes. Does not unmount, delete, or modify real drives — only filters junk notifications.
1 parent 0ebb67e commit 89e73a7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/components/CoreService.vue

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,28 @@ export default {
122122
this.destroyUIEventBus()
123123
},
124124
methods: {
125+
_isValidDiskEvent(evt) {
126+
let p = {}
127+
if (typeof evt?.properties === 'string') {
128+
try { p = JSON.parse(evt.properties) } catch (_) { p = {} }
129+
} else if (typeof evt?.properties === 'object' && evt.properties !== null) {
130+
p = evt.properties
131+
}
132+
133+
const asNum = (v) => {
134+
const n = typeof v === 'number' ? v : parseFloat(v)
135+
return Number.isFinite(n) ? n : NaN
136+
}
137+
138+
const size = asNum(p.size)
139+
if (!size || !Number.isFinite(size) || size <= 0) return false
140+
141+
const path = p['local-storage:path'] || p.path || ''
142+
const mnt = p.mount_point || ''
143+
if (typeof path === 'string' && path.startsWith('/dev/loop') && !mnt) return false
144+
145+
return true
146+
}
125147
createWS(domain) {
126148
let socket
127149
// reference:
@@ -217,6 +239,11 @@ export default {
217239
}
218240
219241
const operateType = eventJson.name.split(':')[2]
242+
if (eventJson.name === 'local-storage:disk:added' && !this._isValidDiskEvent(eventJson)) {
243+
// delete letter which is invalid disk event!
244+
this.$api.users.delLetter(eventJson.uuid)
245+
return
246+
}
220247
const entityUUID = eventJson.properties.serial || eventJson.properties['local-storage:uuid']
221248
switch (eventType) {
222249
case 'usb':

0 commit comments

Comments
 (0)