@@ -23,13 +23,16 @@ function getHFHubCache(): string {
2323const FILES_TO_IGNORE : string [ ] = [ ".DS_Store" ] ;
2424
2525export interface CachedFileInfo {
26- filename : string ;
27- filePath : string ;
28- blobPath : string ;
29- sizeOnDisk : number ;
30-
31- blobLastAccessedAt : Date ;
32- blobLastModifiedAt : Date ;
26+ path : string ;
27+ /**
28+ * Underlying file - which `path` is symlinked to
29+ */
30+ blob : {
31+ size : number ;
32+ path : string ;
33+ lastModifiedAt : Date ;
34+ lastAccessedAt : Date ;
35+ } ;
3336}
3437
3538export interface CachedRevisionInfo {
@@ -43,7 +46,7 @@ export interface CachedRevisionInfo {
4346}
4447
4548export interface CachedRepoInfo {
46- id : RepoId
49+ id : RepoId ;
4750 path : string ;
4851 size : number ;
4952 filesCount : number ;
@@ -147,14 +150,14 @@ export async function scanCachedRepo(repoPath: string): Promise<CachedRepoInfo>
147150
148151 const revisionLastModified =
149152 cachedFiles . length > 0
150- ? Math . max ( ...[ ...cachedFiles ] . map ( ( file ) => file . blobLastModifiedAt . getTime ( ) ) )
153+ ? Math . max ( ...[ ...cachedFiles ] . map ( ( file ) => file . blob . lastModifiedAt . getTime ( ) ) )
151154 : revisionStat . mtimeMs ;
152155
153156 cachedRevisions . push ( {
154157 commitOid : dir ,
155158 files : cachedFiles ,
156159 refs : refsByHash . get ( dir ) || [ ] ,
157- size : [ ...cachedFiles ] . reduce ( ( sum , file ) => sum + file . sizeOnDisk , 0 ) ,
160+ size : [ ...cachedFiles ] . reduce ( ( sum , file ) => sum + file . blob . size , 0 ) ,
158161 path : revisionPath ,
159162 lastModifiedAt : new Date ( revisionLastModified ) ,
160163 } ) ;
@@ -220,12 +223,13 @@ export async function scanSnapshotDir(
220223 const blobStat = await getBlobStat ( blobPath , blobStats ) ;
221224
222225 cachedFiles . push ( {
223- filename : file . name ,
224- filePath : filePath ,
225- blobPath : blobPath ,
226- sizeOnDisk : blobStat . size ,
227- blobLastAccessedAt : new Date ( blobStat . atimeMs ) ,
228- blobLastModifiedAt : new Date ( blobStat . mtimeMs ) ,
226+ path : filePath ,
227+ blob : {
228+ path : blobPath ,
229+ size : blobStat . size ,
230+ lastAccessedAt : new Date ( blobStat . atimeMs ) ,
231+ lastModifiedAt : new Date ( blobStat . mtimeMs ) ,
232+ } ,
229233 } ) ;
230234 }
231235}
@@ -253,11 +257,3 @@ export function parseRepoType(type: string): RepoType {
253257 throw new TypeError ( `Invalid repo type: ${ type } ` ) ;
254258 }
255259}
256-
257- scanCacheDir ( )
258- . then ( ( result ) => {
259- console . log ( result ) ;
260- } )
261- . catch ( ( err : unknown ) => {
262- console . error ( err ) ;
263- } ) ;
0 commit comments