fix: empty block

This commit is contained in:
Moyasee
2025-10-21 21:09:31 +03:00
parent 72e6f1e328
commit 2022ff34cb
2 changed files with 5 additions and 10 deletions

View File

@@ -8,7 +8,6 @@ import { gameAchievementsSublevel, levelKeys, db } from "@main/level";
import { logger } from "@main/services/logger"; import { logger } from "@main/services/logger";
import type { GameShop, User } from "@types"; import type { GameShop, User } from "@types";
const uploadImageToCDN = async (imagePath: string): Promise<string> => { const uploadImageToCDN = async (imagePath: string): Promise<string> => {
const stat = fs.statSync(imagePath); const stat = fs.statSync(imagePath);
const fileBuffer = fs.readFileSync(imagePath); const fileBuffer = fs.readFileSync(imagePath);
@@ -33,7 +32,6 @@ const uploadImageToCDN = async (imagePath: string): Promise<string> => {
return response.achievementImageUrl; return response.achievementImageUrl;
}; };
const storeImageLocally = async (imagePath: string): Promise<string> => { const storeImageLocally = async (imagePath: string): Promise<string> => {
const fileBuffer = fs.readFileSync(imagePath); const fileBuffer = fs.readFileSync(imagePath);
const base64Image = fileBuffer.toString("base64"); const base64Image = fileBuffer.toString("base64");
@@ -42,7 +40,6 @@ const storeImageLocally = async (imagePath: string): Promise<string> => {
return `data:${mimeType?.mime || "image/jpeg"};base64,${base64Image}`; return `data:${mimeType?.mime || "image/jpeg"};base64,${base64Image}`;
}; };
const updateAchievementWithImageUrl = async ( const updateAchievementWithImageUrl = async (
shop: GameShop, shop: GameShop,
gameId: string, gameId: string,
@@ -55,7 +52,6 @@ const updateAchievementWithImageUrl = async (
); );
}; };
export const uploadAchievementImage = async ( export const uploadAchievementImage = async (
gameId: string, gameId: string,
achievementName: string, achievementName: string,
@@ -103,7 +99,6 @@ export const uploadAchievementImage = async (
} }
}; };
const uploadAchievementImageEvent = async ( const uploadAchievementImageEvent = async (
_event: Electron.IpcMainInvokeEvent, _event: Electron.IpcMainInvokeEvent,
params: { params: {

View File

@@ -5,11 +5,10 @@ import { app } from "electron";
import { logger } from "./logger"; import { logger } from "./logger";
export class ScreenshotService { export class ScreenshotService {
private static readonly SCREENSHOT_QUALITY = 80; private static readonly SCREENSHOT_QUALITY = 80;
private static readonly SCREENSHOT_FORMAT = "jpeg"; private static readonly SCREENSHOT_FORMAT = "jpeg";
private static readonly MAX_WIDTH = 1280; private static readonly MAX_WIDTH = 1280;
private static readonly MAX_HEIGHT = 720; private static readonly MAX_HEIGHT = 720;
private static compressImage( private static compressImage(
image: Electron.NativeImage image: Electron.NativeImage
@@ -147,7 +146,7 @@ export class ScreenshotService {
} }
const cleanupEmptyDirs = (dir: string) => { const cleanupEmptyDirs = (dir: string) => {
if (dir === screenshotsDir) return; if (dir === screenshotsDir) return;
try { try {
const items = fs.readdirSync(dir); const items = fs.readdirSync(dir);
@@ -156,6 +155,7 @@ export class ScreenshotService {
logger.log(`Cleaned up empty directory: ${dir}`); logger.log(`Cleaned up empty directory: ${dir}`);
} }
} catch (error) { } catch (error) {
logger.error(`Failed to read directory ${dir}:`, error);
} }
}; };