try better error handling at daily full backup
This commit is contained in:
parent
6d18be7ee3
commit
5ce5a25daf
|
@ -194,26 +194,39 @@ export async function createPngBackup(
|
||||||
}
|
}
|
||||||
for (let y = 0; y < chunksXY; y++) {
|
for (let y = 0; y < chunksXY; y++) {
|
||||||
const key = `ch:${id}:${x}:${y}`;
|
const key = `ch:${id}:${x}:${y}`;
|
||||||
/*
|
try {
|
||||||
* await on every iteration is fine because less resource usage
|
/*
|
||||||
* in exchange for higher execution time is wanted.
|
* await on every iteration is fine because less resource usage
|
||||||
*/
|
* in exchange for higher execution time is wanted.
|
||||||
// eslint-disable-next-line no-await-in-loop
|
*/
|
||||||
const chunk = await redisClient.getAsync(key);
|
|
||||||
if (chunk) {
|
|
||||||
const textureBuffer = palette.buffer2RGB(chunk);
|
|
||||||
const filename = `${xBackupDir}/${y}.png`;
|
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
await sharp(
|
const chunk = await redisClient.getAsync(key);
|
||||||
Buffer.from(textureBuffer.buffer), {
|
if (chunk) {
|
||||||
raw: {
|
if (chunk.length === TILE_SIZE * TILE_SIZE) {
|
||||||
width: TILE_SIZE,
|
const textureBuffer = palette.buffer2RGB(chunk);
|
||||||
height: TILE_SIZE,
|
const filename = `${xBackupDir}/${y}.png`;
|
||||||
channels: 3,
|
// eslint-disable-next-line no-await-in-loop
|
||||||
},
|
await sharp(
|
||||||
},
|
Buffer.from(textureBuffer.buffer), {
|
||||||
).toFile(filename);
|
raw: {
|
||||||
amount += 1;
|
width: TILE_SIZE,
|
||||||
|
height: TILE_SIZE,
|
||||||
|
channels: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
).toFile(filename);
|
||||||
|
amount += 1;
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
`Chunk ${x},${y} of canvas ${id} has invalid length ${chunk.length}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
console.log(
|
||||||
|
`Couldn't create PNG backup of chunk ${x},${y} of canvas ${id}.`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user