@@ -13,17 +13,17 @@ export interface CacheStats {
1313}
1414
1515export 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}
0 commit comments