@@ -698,10 +698,8 @@ function setLogger(logger) {
698
698
699
699
async function withSubdir ( prefix , fn , options ) {
700
700
const ctx = prefixStackStorage . getStore ( ) ;
701
- const tmpDir = path . resolve (
702
- ctx ? ctx . value : _getTmpDir ( ) ,
703
- prefix
704
- ) ;
701
+ const base = ctx ? ctx . value : _getTmpDir ( ) ;
702
+ const tmpDir = path . resolve ( base , prefix ) ;
705
703
const logTags = {
706
704
...( options && options . logTags ? options . logTags : { } ) ,
707
705
path : tmpDir
@@ -716,9 +714,18 @@ async function withSubdir(prefix, fn, options) {
716
714
const cleanup = async ( ) => {
717
715
_logger . info ( logTags , "lib-tmp.gc.start" ) ;
718
716
const t0 = Date . now ( ) ;
717
+ const stat0 = await fsp . statfs ( base ) ;
719
718
try {
720
719
await fsp . rm ( tmpDir , { force : true , recursive : true , maxRetries : 5 } ) ;
721
- _logger . info ( { ...logTags , duration : Date . now ( ) - t0 } , "lib-tmp.gc.end" ) ;
720
+ const stat1 = await fsp . statfs ( base ) ;
721
+ _logger . info (
722
+ {
723
+ ...logTags ,
724
+ duration : Date . now ( ) - t0 ,
725
+ size : ( stat1 . bavail - stat0 . bavail ) * stat0 . bsize
726
+ } ,
727
+ "lib-tmp.gc.end"
728
+ ) ;
722
729
} catch ( error ) {
723
730
_logger . info ( { ...logTags , duration : Date . now ( ) - t0 , error } , "lib-tmp.gc.error" ) ;
724
731
}
0 commit comments