better chunk error handling if redis data is invalid for whatever reason
This commit is contained in:
parent
5ce5a25daf
commit
59e4c757b6
|
@ -53,7 +53,7 @@ export async function imageABGR2Canvas(
|
|||
for (let cx = ucx; cx <= lcx; cx += 1) {
|
||||
for (let cy = ucy; cy <= lcy; cy += 1) {
|
||||
chunk = await RedisCanvas.getChunk(canvasId, cx, cy);
|
||||
chunk = (chunk)
|
||||
chunk = (chunk && chunk.length === TILE_SIZE * TILE_SIZE)
|
||||
? new Uint8Array(chunk)
|
||||
: new Uint8Array(TILE_SIZE * TILE_SIZE);
|
||||
// offset of chunk in image
|
||||
|
@ -130,7 +130,7 @@ export async function imagemask2Canvas(
|
|||
for (let cx = ucx; cx <= lcx; cx += 1) {
|
||||
for (let cy = ucy; cy <= lcy; cy += 1) {
|
||||
chunk = await RedisCanvas.getChunk(canvasId, cx, cy);
|
||||
chunk = (chunk)
|
||||
chunk = (chunk && chunk.length === TILE_SIZE * TILE_SIZE)
|
||||
? new Uint8Array(chunk)
|
||||
: new Uint8Array(TILE_SIZE * TILE_SIZE);
|
||||
// offset of chunk in image
|
||||
|
@ -201,7 +201,7 @@ export async function protectCanvasArea(
|
|||
for (let cx = ucx; cx <= lcx; cx += 1) {
|
||||
for (let cy = ucy; cy <= lcy; cy += 1) {
|
||||
chunk = await RedisCanvas.getChunk(canvasId, cx, cy);
|
||||
if (!chunk) {
|
||||
if (!chunk || chunk.length !== TILE_SIZE * TILE_SIZE) {
|
||||
continue;
|
||||
}
|
||||
chunk = new Uint8Array(chunk);
|
||||
|
|
|
@ -143,7 +143,7 @@ export async function createZoomTileFromChunk(
|
|||
for (let dy = 0; dy < TILE_ZOOM_LEVEL; dy += 1) {
|
||||
for (let dx = 0; dx < TILE_ZOOM_LEVEL; dx += 1) {
|
||||
chunk = await redisCanvas.getChunk(canvasId, xabs + dx, yabs + dy);
|
||||
if (!chunk) {
|
||||
if (!chunk || chunk.length !== TILE_SIZE * TILE_SIZE) {
|
||||
na.push([dx, dy]);
|
||||
continue;
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ export async function createTexture(
|
|||
for (let dy = 0; dy < amount; dy += 1) {
|
||||
for (let dx = 0; dx < amount; dx += 1) {
|
||||
chunk = await redisCanvas.getChunk(canvasId, dx, dy);
|
||||
if (!chunk) {
|
||||
if (!chunk || chunk.length !== TILE_SIZE * TILE_SIZE) {
|
||||
na.push([dx, dy]);
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user