Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions website/server/src/domains/pack/processZipFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { type CliOptions, runDefaultAction, setLogLevel } from 'repomix';
import type { PackOptions, PackResult } from '../../types.js';
import { AppError } from '../../utils/errorHandler.js';
import { logMemoryUsage } from '../../utils/logger.js';
import { generateCacheKey } from './utils/cache.js';
import { cleanupTempDirectory, copyOutputToCurrentDirectory, createTempDirectory } from './utils/fileUtils.js';
import { cache } from './utils/sharedInstance.js';

// Enhanced ZIP extraction limits
const ZIP_SECURITY_LIMITS = {
Expand All @@ -27,14 +25,6 @@ export async function processZipFile(file: File, format: string, options: PackOp
throw new AppError('File is required for file processing', 400);
}

const cacheKey = generateCacheKey(`${file.name}-${file.size}-${file.lastModified}`, format, options, 'file');

// Check if the result is already cached
const cachedResult = await cache.get(cacheKey);
if (cachedResult) {
return cachedResult;
}

const outputFilePath = `repomix-output-${randomUUID()}.txt`;

// Create CLI options
Expand Down Expand Up @@ -101,9 +91,6 @@ export async function processZipFile(file: File, format: string, options: PackOp
},
};

// Save the result to cache
await cache.set(cacheKey, packResultData);

// Log memory usage after processing
logMemoryUsage('ZIP file processing completed', {
fileName: file.name,
Expand Down
2 changes: 1 addition & 1 deletion website/server/src/domains/pack/utils/sharedInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { RateLimiter } from '../../../utils/rateLimit.js';
import { RequestCache } from './cache.js';

// Create shared instances
export const cache = new RequestCache<PackResult>(180); // 3 minutes cache
export const cache = new RequestCache<PackResult>(600); // 10 minutes cache
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better maintainability and flexibility, consider making the cache TTL configurable via an environment variable. This would allow for easier adjustments in different environments without requiring code changes, and it follows the pattern already used for the rate limiter configuration in this file.

Suggested change
export const cache = new RequestCache<PackResult>(600); // 10 minutes cache
export const cache = new RequestCache<PackResult>(parseInt(process.env.REMOTE_REPO_CACHE_TTL_SECONDS || '600', 10)); // 10 minutes cache by default

export const rateLimiter = new RateLimiter(60_000, process.env.NODE_ENV === 'development' ? 10 : 3); // 10 requests per minute in dev, 3 in production
Loading