Skip to content

Commit 76cb757

Browse files
committed
Add debug stuff for #404
1 parent b110101 commit 76cb757

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/services/DockerService.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ export default class DockerService {
142142
*/
143143
public static async updateContainer(containerId: string) {
144144
try {
145+
logger.info(`Updating container: ${containerId}`);
146+
145147
const container = DockerService.docker.getContainer(containerId);
146148
const info = await container.inspect();
147149
const oldImageId = info.Image;
@@ -159,6 +161,7 @@ export default class DockerService {
159161
let lastPublishTime = 0;
160162

161163
await DockerService.docker.pull(image, async (err: any, stream: any) => {
164+
logger.info("Pulling image: " + image);
162165
if (err) {
163166
logger.error("Pulling Error: " + err);
164167
return;
@@ -207,7 +210,7 @@ export default class DockerService {
207210
}
208211
});
209212

210-
HomeassistantService.publishUpdateProgressMessage(info, mqttClient, 100, false);
213+
await HomeassistantService.publishUpdateProgressMessage(info, mqttClient, 100, false);
211214
this.updatingContainers = this.updatingContainers.filter((id) => id !== containerId);
212215

213216
return newContainer;

src/services/HomeassistantService.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,13 @@ export default class HomeassistantService {
364364
container = DockerService.docker.getContainer(container).inspect();
365365
}
366366

367-
const image = container.Config.Image.split(":")[0];
368-
const formatedImage = image.replace(/[\/.:;,+*?@^$%#!&"'`|<>{}\[\]()-\s\u0000-\u001F\u007F]/g, "_");
367+
if (!container) {
368+
logger.error(`ABORT: Failed to find container ${container}`);
369+
return;
370+
}
371+
372+
const image = container?.Config?.Image?.split(":")[0];
373+
const formatedImage = image?.replace(/[\/.:;,+*?@^$%#!&"'`|<>{}\[\]()-\s\u0000-\u001F\u007F]/g, "_");
369374

370375
// Update entity payload
371376
const updateTopic = `${config.mqtt.topic}/${formatedImage}/update`;

0 commit comments

Comments
 (0)