@@ -171,6 +171,7 @@ function dfs:string()
171171 return self .path
172172end
173173
174+ --- @return fun (): dummyfs ?
174175function dfs :listDirectory ()
175176 local dir = self :_open ()
176177 if type (dir ) ~= ' table' then
263264
264265--- @param path string | fs.path | dummyfs
265266--- @param option table
266- --- @return fs.path ?
267+ --- @return fs.path | dummyfs ?
267268local function fsAbsolute (path , option )
268269 if type (path ) == ' string' then
269270 local suc , res = pcall (fs .path , path )
@@ -459,7 +460,7 @@ local function fileRemove(path, option)
459460end
460461
461462--- @param source fs.path | dummyfs ?
462- --- @param target fs.path ?
463+ --- @param target fs.path | dummyfs ?
463464--- @param option table
464465local function fileCopy (source , target , option )
465466 if not source or not target then
@@ -495,7 +496,7 @@ local function fileCopy(source, target, option)
495496end
496497
497498--- @param source fs.path | dummyfs ?
498- --- @param target fs.path ?
499+ --- @param target fs.path | dummyfs ?
499500--- @param option table
500501local function fileSync (source , target , option )
501502 if not source or not target then
@@ -507,8 +508,16 @@ local function fileSync(source, target, option)
507508 if isDir1 then
508509 if isDir2 then
509510 local fileList = m .fileList ()
510- for filePath in fs .pairs (target ) do
511- fileList [filePath ] = true
511+ if type (target ) == ' table' then
512+ --- @cast target dummyfs
513+ for filePath in target :listDirectory () do
514+ fileList [filePath ] = true
515+ end
516+ else
517+ --- @cast target fs.path
518+ for filePath in fs .pairs (target ) do
519+ fileList [filePath ] = true
520+ end
512521 end
513522 for filePath in fsPairs (source , option ) do
514523 local name = filePath :filename ():string ()
0 commit comments