Shorten temp directory (#17901)

This commit is contained in:
joshualitt
2026-02-06 08:10:17 -08:00
committed by GitHub
parent 30354892b3
commit 6fb3b09003
24 changed files with 989 additions and 27 deletions
+6 -3
View File
@@ -256,8 +256,11 @@ const saveFileWithXclip = async (tempFilePath: string) => {
* @param targetDir The root directory of the current project.
* @returns The absolute path to the images directory.
*/
function getProjectClipboardImagesDir(targetDir: string): string {
async function getProjectClipboardImagesDir(
targetDir: string,
): Promise<string> {
const storage = new Storage(targetDir);
await storage.initialize();
const baseDir = storage.getProjectTempDir();
return path.join(baseDir, 'images');
}
@@ -271,7 +274,7 @@ export async function saveClipboardImage(
targetDir: string,
): Promise<string | null> {
try {
const tempDir = getProjectClipboardImagesDir(targetDir);
const tempDir = await getProjectClipboardImagesDir(targetDir);
await fs.mkdir(tempDir, { recursive: true });
// Generate a unique filename with timestamp
@@ -396,7 +399,7 @@ export async function cleanupOldClipboardImages(
targetDir: string,
): Promise<void> {
try {
const tempDir = getProjectClipboardImagesDir(targetDir);
const tempDir = await getProjectClipboardImagesDir(targetDir);
const files = await fs.readdir(tempDir);
const oneHourAgo = Date.now() - 60 * 60 * 1000;