Compare commits

...

3 Commits

Author SHA1 Message Date
Maksim Karasev e6b499f72b Bump version to 1.2.1 2023-05-19 17:34:09 +03:00
Maksim Karasev e99da6e3d6 Switch to using native fs.promises 2023-05-19 17:33:17 +03:00
Maksim Karasev 6a086453c6 Small caching configuration changes 2023-05-19 17:32:37 +03:00
5 changed files with 8 additions and 11 deletions

View File

@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "personal-gallery",
"version": "1.2.0",
"version": "1.2.1",
"description": "",
"scripts": {
"server-dev": "yarn workspace server dev",

View File

@ -1,6 +1,6 @@
{
"name": "server",
"version": "1.2.0",
"version": "1.2.1",
"description": "",
"main": "index.js",
"scripts": {

View File

@ -2,8 +2,7 @@
import sharp from 'sharp';
import ffmpeg from 'fluent-ffmpeg';
import tmp from 'tmp';
import fs from 'fs';
import util from 'util';
import { promises as fs } from "fs";
import path from 'path';
import { FFMPEG_EXISTS, IMAGE_DIR } from '../utils/config';
import { getImage } from './imageService';
@ -54,8 +53,6 @@ export const getThumbnail = async (
height: number = 160,
): Promise<Buffer> => {
const image = await getImage(filename);
const readFilePromise = util.promisify(fs.readFile);
const unlinkFilePromise = util.promisify(fs.unlink);
let { imagebuffer } = image;
logger.verbose('Thumbnail cache miss.');
// Take a screenshot from videos
@ -71,8 +68,8 @@ export const getThumbnail = async (
path.join(IMAGE_DIR, filename),
tmpDir.name,
);
imagebuffer = await readFilePromise(`${tmpDir.name}/temp.png`);
await unlinkFilePromise(`${tmpDir.name}/temp.png`);
imagebuffer = await fs.readFile(`${tmpDir.name}/temp.png`);
await fs.unlink(`${tmpDir.name}/temp.png`);
} catch (e: any) {
logger.error(`${e.name}:${e.message}`);
}

View File

@ -16,7 +16,7 @@ if (typeof REDIS_HOST !== 'undefined') {
port: REDIS_PORT,
password: REDIS_PASSWORD,
db: 0,
ttl: 600,
ttl: 60 * 60 * 24 * 365,
});
} else if (typeof CACHE_DIR !== 'undefined') {
thumbnailCache = cacheManager.caching({
@ -25,7 +25,7 @@ if (typeof REDIS_HOST !== 'undefined') {
options: {
path: CACHE_DIR, // path for cached files
subdirs: true, // create subdirectories to reduce the files in a single dir (default: false)
zip: true, // zip files to save diskspace (default: false)
zip: false, // zip files to save diskspace (default: false)
},
});
} else {

View File

@ -1,6 +1,6 @@
{
"name": "web",
"version": "1.2.0",
"version": "1.2.1",
"private": true,
"dependencies": {
"@emotion/react": "^11.10.5",