mirror of
https://github.com/unraid/api.git
synced 2026-05-08 08:00:19 -05:00
fix: use var not varstate on hostname change
This commit is contained in:
+12
-4
@@ -331,13 +331,21 @@ bus.on('slots', async () => {
|
||||
});
|
||||
});
|
||||
|
||||
let hostname;
|
||||
|
||||
// Update info/hostname when hostname changes
|
||||
bus.on('var', async data => {
|
||||
const hostname = data.varstate.node.name;
|
||||
// @todo: Create a system user for this
|
||||
const user = usersState.findOne({ name: 'root' });
|
||||
// Hostname changed
|
||||
if (hostname !== data.var.node.name) {
|
||||
const user = usersState.findOne({ name: 'root' });
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user) {
|
||||
// Update cache
|
||||
hostname = data.var.node.name;
|
||||
|
||||
// Publish new hostname
|
||||
await publish('info', 'UPDATED', {
|
||||
os: {
|
||||
hostname
|
||||
|
||||
Reference in New Issue
Block a user