fix cache not cleared
This commit is contained in:
parent
2e628038ae
commit
081cfd2b2b
|
@ -1,6 +1,6 @@
|
||||||
import { exec, ExecException } from 'child_process';
|
import { exec, ExecException } from 'child_process';
|
||||||
import { app } from 'electron';
|
import { app } from 'electron';
|
||||||
import { existsSync } from 'fs';
|
import { existsSync, rmSync } from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { mkdir, readFile, writeFile } from 'promise-fs';
|
import { mkdir, readFile, writeFile } from 'promise-fs';
|
||||||
import { logErrorSentry } from './sentry';
|
import { logErrorSentry } from './sentry';
|
||||||
|
@ -8,16 +8,18 @@ import { logErrorSentry } from './sentry';
|
||||||
export async function convertHEIC(
|
export async function convertHEIC(
|
||||||
heicFileData: Uint8Array
|
heicFileData: Uint8Array
|
||||||
): Promise<Uint8Array> {
|
): Promise<Uint8Array> {
|
||||||
|
let tempInputFilePath: string;
|
||||||
|
let tempOutputFilePath: string;
|
||||||
try {
|
try {
|
||||||
const tempDir = path.join(app.getPath('temp'), 'ente');
|
const tempDir = path.join(app.getPath('temp'), 'ente');
|
||||||
if (!existsSync(tempDir)) {
|
if (!existsSync(tempDir)) {
|
||||||
await mkdir(tempDir);
|
await mkdir(tempDir);
|
||||||
}
|
}
|
||||||
const tempInputFilePath = path.join(
|
tempInputFilePath = path.join(
|
||||||
tempDir,
|
tempDir,
|
||||||
generateRandomName(10) + '.heic'
|
generateRandomName(10) + '.heic'
|
||||||
);
|
);
|
||||||
const tempOutputFilePath = path.join(
|
tempOutputFilePath = path.join(
|
||||||
tempDir,
|
tempDir,
|
||||||
generateRandomName(10) + '.jpeg'
|
generateRandomName(10) + '.jpeg'
|
||||||
);
|
);
|
||||||
|
@ -48,6 +50,17 @@ export async function convertHEIC(
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logErrorSentry(e, 'failed to convert heic');
|
logErrorSentry(e, 'failed to convert heic');
|
||||||
throw e;
|
throw e;
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
rmSync(tempInputFilePath);
|
||||||
|
} catch (e) {
|
||||||
|
logErrorSentry(e, 'failed to remove tempInputFile');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
rmSync(tempOutputFilePath);
|
||||||
|
} catch (e) {
|
||||||
|
logErrorSentry(e, 'failed to remove tempOutputFile');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue