Skip to content

Commit 2acaee7

Browse files
committed
refactor: rename cacheDir to repoCacheDir to disambiguate from ConfigLoader.cacheDir
1 parent d07ed9c commit 2acaee7

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/proxy/processors/push-action/cache-manager.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ export interface CacheStats {
1313
}
1414

1515
export class CacheManager {
16-
private cacheDir: string;
16+
private repoCacheDir: string;
1717
private maxSizeGB: number;
1818
private maxRepositories: number;
1919
private mutex: Promise<void> = Promise.resolve();
2020

2121
constructor(
22-
cacheDir: string = './.remote/cache',
22+
repoCacheDir: string = './.remote/cache',
2323
maxSizeGB: number = 2,
2424
maxRepositories: number = 50,
2525
) {
26-
this.cacheDir = cacheDir;
26+
this.repoCacheDir = repoCacheDir;
2727
this.maxSizeGB = maxSizeGB;
2828
this.maxRepositories = maxRepositories;
2929
}
@@ -52,7 +52,7 @@ export class CacheManager {
5252
*/
5353
async touchRepository(repoName: string): Promise<void> {
5454
return this.acquireLock(() => {
55-
const repoPath = path.join(this.cacheDir, repoName);
55+
const repoPath = path.join(this.repoCacheDir, repoName);
5656
if (fs.existsSync(repoPath)) {
5757
const now = new Date();
5858
fs.utimesSync(repoPath, now, now);
@@ -64,7 +64,7 @@ export class CacheManager {
6464
* Get cache statistics
6565
*/
6666
getCacheStats(): CacheStats {
67-
if (!fs.existsSync(this.cacheDir)) {
67+
if (!fs.existsSync(this.repoCacheDir)) {
6868
return {
6969
totalRepositories: 0,
7070
totalSizeBytes: 0,
@@ -75,11 +75,11 @@ export class CacheManager {
7575
const repositories: Array<{ name: string; sizeBytes: number; lastAccessed: Date }> = [];
7676
let totalSizeBytes = 0;
7777

78-
const entries = fs.readdirSync(this.cacheDir, { withFileTypes: true });
78+
const entries = fs.readdirSync(this.repoCacheDir, { withFileTypes: true });
7979

8080
for (const entry of entries) {
8181
if (entry.isDirectory()) {
82-
const repoPath = path.join(this.cacheDir, entry.name);
82+
const repoPath = path.join(this.repoCacheDir, entry.name);
8383
const sizeBytes = this.getDirectorySize(repoPath);
8484
const stats = fs.statSync(repoPath);
8585

@@ -141,7 +141,7 @@ export class CacheManager {
141141
* Remove specific repository from cache
142142
*/
143143
private removeRepository(repoName: string): void {
144-
const repoPath = path.join(this.cacheDir, repoName);
144+
const repoPath = path.join(this.repoCacheDir, repoName);
145145
if (fs.existsSync(repoPath)) {
146146
fs.rmSync(repoPath, { recursive: true, force: true });
147147
}
@@ -189,7 +189,7 @@ export class CacheManager {
189189
return {
190190
maxSizeGB: this.maxSizeGB,
191191
maxRepositories: this.maxRepositories,
192-
cacheDir: this.cacheDir,
192+
repoCacheDir: this.repoCacheDir,
193193
};
194194
}
195195
}

src/proxy/processors/push-action/pullRemote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const exec = async (req: any, action: Action): Promise<Action> => {
1212
try {
1313
// Get cache directories from configuration
1414
const config = cacheManager.getConfig();
15-
const BARE_CACHE = config.cacheDir;
15+
const BARE_CACHE = config.repoCacheDir;
1616
const WORK_DIR = path.join(path.dirname(BARE_CACHE), 'work');
1717

1818
// Paths for hybrid architecture

test/processors/cacheManager.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ describe('CacheManager', () => {
158158
expect(config).to.deep.equal({
159159
maxSizeGB: 0.001,
160160
maxRepositories: 3,
161-
cacheDir: testCacheDir,
161+
repoCacheDir: testCacheDir,
162162
});
163163
});
164164
});

0 commit comments

Comments
 (0)