mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-18 18:11:02 -07:00
Shorten temp directory (#17901)
This commit is contained in:
@@ -45,6 +45,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
},
|
||||
Storage: class {
|
||||
getProjectTempDir = vi.fn(() => '/tmp/global');
|
||||
initialize = vi.fn(() => Promise.resolve(undefined));
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
spawnAsync: vi.fn(),
|
||||
Storage: class {
|
||||
getProjectTempDir = vi.fn(() => "C:\\User's Files");
|
||||
initialize = vi.fn(() => Promise.resolve(undefined));
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user