11/* eslint-disable @typescript-eslint/no-unused-vars */
22import { fs , vol } from 'memfs'
3- import type { Stats , ReadStream } from 'fs'
3+ import type { ReadStream , BigIntStats } from 'fs'
44import { Transform , TransformCallback } from 'stream'
55import * as path from 'path'
6- // import mkdir = require('mkdirp')
7- // import del = require('del')
86
97import { FsApi , FileDescriptor , Credentials , Fs , filetype , MakeId } from '$src/services/Fs'
10- // import { size } from '$src/utils/size'
118import { throttle } from '$src/utils/throttle'
129import { isWin , HOME_DIR } from '$src/utils/platform'
1310import { VirtualWatch } from '$src/services/plugins/VirtualWatch'
@@ -191,8 +188,8 @@ export class VirtualApi implements FsApi {
191188 }
192189
193190 async isDir ( path : string , transferId = - 1 ) : Promise < boolean > {
194- const lstat = vol . lstatSync ( path )
195- const stat = vol . statSync ( path )
191+ const lstat = vol . lstatSync ( path , { bigint : true } )
192+ const stat = vol . statSync ( path , { bigint : true } )
196193 return stat . isDirectory ( ) || lstat . isDirectory ( )
197194 }
198195
@@ -212,7 +209,7 @@ export class VirtualApi implements FsApi {
212209 async stat ( fullPath : string , transferId = - 1 ) : Promise < FileDescriptor > {
213210 try {
214211 const format = path . parse ( fullPath )
215- const stats = vol . lstatSync ( fullPath )
212+ const stats = vol . lstatSync ( fullPath , { bigint : true } )
216213 const file : FileDescriptor = {
217214 dir : format . dir ,
218215 fullname : format . base ,
@@ -221,12 +218,13 @@ export class VirtualApi implements FsApi {
221218 cDate : stats . ctime ,
222219 mDate : stats . mtime ,
223220 bDate : stats . birthtime ,
224- length : stats . size ,
225- mode : stats . mode ,
221+ length : Number ( stats . size ) ,
222+ mode : Number ( stats . mode ) ,
226223 isDir : stats . isDirectory ( ) ,
227224 readonly : false ,
228225 type :
229- ( ! stats . isDirectory ( ) && filetype ( stats . mode , stats . gid , stats . uid , format . ext . toLowerCase ( ) ) ) ||
226+ ( ! stats . isDirectory ( ) &&
227+ filetype ( Number ( stats . mode ) , Number ( stats . gid ) , Number ( stats . uid ) , format . ext . toLowerCase ( ) ) ) ||
230228 '' ,
231229 isSym : stats . isSymbolicLink ( ) ,
232230 target : ( stats . isSymbolicLink ( ) && vol . readlinkSync ( fullPath ) ) || null ,
@@ -291,16 +289,16 @@ export class VirtualApi implements FsApi {
291289 static fileFromPath ( fullPath : string ) : FileDescriptor {
292290 const format = path . parse ( fullPath )
293291 let name = fullPath
294- let stats : Partial < Stats > = null
292+ let stats : Partial < BigIntStats > = null
295293 let targetStats = null
296294
297295 try {
298296 // do not follow symlinks first
299- stats = vol . lstatSync ( fullPath )
297+ stats = vol . lstatSync ( fullPath , { bigint : true } )
300298 if ( stats . isSymbolicLink ( ) ) {
301299 // get link target path first
302300 name = vol . readlinkSync ( fullPath ) as string
303- targetStats = vol . statSync ( fullPath )
301+ targetStats = vol . statSync ( fullPath , { bigint : true } )
304302 }
305303 } catch ( err ) {
306304 console . warn ( 'error getting stats for' , fullPath , err )
@@ -312,12 +310,12 @@ export class VirtualApi implements FsApi {
312310 ctime : new Date ( ) ,
313311 mtime : new Date ( ) ,
314312 birthtime : new Date ( ) ,
315- size : stats ? stats . size : 0 ,
313+ size : stats ? stats . size : 0n ,
316314 isDirectory : ( ) : boolean => isDir ,
317- mode : - 1 ,
315+ mode : - 1n ,
318316 isSymbolicLink : ( ) : boolean => isSymLink ,
319- ino : 0 ,
320- dev : 0 ,
317+ ino : 0n ,
318+ dev : 0n ,
321319 }
322320 }
323321
@@ -332,12 +330,13 @@ export class VirtualApi implements FsApi {
332330 cDate : stats . ctime ,
333331 mDate : stats . mtime ,
334332 bDate : stats . birthtime ,
335- length : stats . size ,
336- mode : mode ,
333+ length : Number ( stats . size ) ,
334+ mode : Number ( mode ) ,
337335 isDir : targetStats ? targetStats . isDirectory ( ) : stats . isDirectory ( ) ,
338336 readonly : false ,
339337 type :
340- ( ! ( targetStats ? targetStats . isDirectory ( ) : stats . isDirectory ( ) ) && filetype ( mode , 0 , 0 , extension ) ) ||
338+ ( ! ( targetStats ? targetStats . isDirectory ( ) : stats . isDirectory ( ) ) &&
339+ filetype ( Number ( mode ) , 0 , 0 , extension ) ) ||
341340 '' ,
342341 isSym : stats . isSymbolicLink ( ) ,
343342 target : ( stats . isSymbolicLink ( ) && name ) || null ,
@@ -481,7 +480,7 @@ export class VirtualApi implements FsApi {
481480
482481export function FolderExists ( path : string ) : boolean {
483482 try {
484- return vol . existsSync ( path ) && vol . lstatSync ( path ) . isDirectory ( )
483+ return vol . existsSync ( path ) && vol . lstatSync ( path , { bigint : true } ) . isDirectory ( )
485484 } catch ( err ) {
486485 return false
487486 }
0 commit comments