Skip to content

Commit

Permalink
add extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ledyba committed May 10, 2022
1 parent 35b6875 commit cfa4164
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/src/cmd/regenerate-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ async function main() {
}
let processed = 0;
for (const entity of entities) {
console.log(`Processing: (type=${entity.type}, ${processed+1}/${entities.length}): ${entity.id}`);
await shelf.regenerateEntityCache(entity);
++processed;
console.log(`Done: (type=${entity.type}, ${processed}/${entities.length}): ${entity.id}`);
}
} finally {
await repo.close();
Expand Down
1 change: 1 addition & 0 deletions server/src/lib/media/Convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export async function makeImageIcon(src: string, dst: string, size: number) {
const r = await spawn('magick', [
'convert',
src,
'-coalesce',
'-resize', `${size}x${size}^`,
'-gravity', 'center',
'-extent', `${size}x${size}`,
Expand Down
9 changes: 7 additions & 2 deletions server/src/shelf/Shelf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,13 @@ class Shelf {
return path.join(tempDir, 'medium.jpg');
})();
const iconPath = path.join(tempDir, 'icon.jpg');
const originalPath = path.join(...((await this.storage.original.fetch(entity.id))!!));
const probeResult = await probe(originalPath);
const [originalPath, probeResult] = await (async () => {
const [base, filename] = (await this.storage.original.fetch(entity.id))!!;
const probeResult = await probe(path.join(base, filename));
const originalPath = path.join(tempDir, `original.${probeResult.ext}`);
await fs.copyFile(path.join(base, filename), originalPath);
return [originalPath, probeResult];
})();
let newEntity: Entity;
switch (entity.type) {
case 'image': {
Expand Down

0 comments on commit cfa4164

Please sign in to comment.