diff --git a/src/data/models/RedisCanvas.js b/src/data/models/RedisCanvas.js index e953969f..4caf8219 100644 --- a/src/data/models/RedisCanvas.js +++ b/src/data/models/RedisCanvas.js @@ -1,7 +1,11 @@ /* @flow */ import { getChunkOfPixel, getOffsetOfPixel } from '../../core/utils'; -import { TILE_SIZE, THREE_CANVAS_HEIGHT } from '../../core/constants'; +import { + TILE_SIZE, + THREE_TILE_SIZE, + THREE_CANVAS_HEIGHT, +} from '../../core/constants'; import canvases from '../../canvases.json'; import logger from '../../core/logger'; @@ -13,7 +17,7 @@ const UINT_SIZE = 'u8'; const EMPTY_CACA = new Uint8Array(TILE_SIZE * TILE_SIZE); const EMPTY_CHUNK_BUFFER = Buffer.from(EMPTY_CACA.buffer); const THREE_EMPTY_CACA = new Uint8Array( - TILE_SIZE * TILE_SIZE * THREE_CANVAS_HEIGHT, + THREE_TILE_SIZE * THREE_TILE_SIZE * THREE_CANVAS_HEIGHT, ); const THREE_EMPTY_CHUNK_BUFFER = Buffer.from(THREE_EMPTY_CACA.buffer); diff --git a/src/routes/chunks.js b/src/routes/chunks.js index bd1b31cd..aec3d784 100644 --- a/src/routes/chunks.js +++ b/src/routes/chunks.js @@ -8,7 +8,11 @@ import type { Request, Response } from 'express'; import etag from 'etag'; import RedisCanvas from '../data/models/RedisCanvas'; -import { TILE_SIZE } from '../core/constants'; +import { + TILE_SIZE, + THREE_TILE_SIZE, + THREE_CANVAS_HEIGHT, +} from '../core/constants'; import logger from '../core/logger'; /* @@ -49,8 +53,10 @@ export default async (req: Request, res: Response, next) => { } // for temporary logging to see if we have invalid chunks in redis - if (chunk.length !== TILE_SIZE * TILE_SIZE) { - logger.error(`Chunk ${x},${y},${z} has invalid length ${chunk.length}!`); + + if (chunk.length !== TILE_SIZE * TILE_SIZE + && chunk.length !== (THREE_TILE_SIZE ** 2) * THREE_CANVAS_HEIGHT) { + logger.error(`Chunk ${x},${y}/${c} has invalid length ${chunk.length}!`); } const curEtag = etag(chunk, { weak: true });