@@ -181,7 +181,7 @@ local job_complete = function(context)
181181end
182182
183183local function create_node (context , node )
184- local success3 , item = pcall (file_items .create_item , context , node .path , node .type )
184+ local success , item = pcall (file_items .create_item , context , node .path , node .type )
185185end
186186
187187local function process_node (context , path )
@@ -399,26 +399,26 @@ local function sync_scan(context, path_to_scan)
399399 end
400400 job_complete (context )
401401 else -- scan_mode == "shallow"
402- local success , dir , err = pcall ( uv .fs_opendir , path_to_scan , nil , 1000 )
403- if err or not success then
404- log . error ( " Error opening dir: " , err )
405- end
406- --- @cast dir uv.luv_dir_t
407- local success2 , stats = pcall ( uv . fs_readdir , dir )
408- if success2 and stats then
409- for _ , stat in ipairs ( stats ) do
410- local path = utils . path_join ( path_to_scan , stat .name )
411- local success3 , item = pcall ( file_items . create_item , context , path , stat . type )
412- if success3 then
413- if context . recursive and stat . type == " directory " then
414- table.insert ( context . paths_to_load , path )
402+ local dir , err = uv .fs_opendir ( path_to_scan , nil , 1000 )
403+ if dir then
404+ local stats = uv . fs_readdir ( dir )
405+ if stats then
406+ for _ , stat in ipairs ( stats ) do
407+ local path = utils . path_join ( path_to_scan , stat . name )
408+ local success , item = pcall ( file_items . create_item , context , path , stat . type )
409+ if success then
410+ if context . recursive and stat .type == " directory " then
411+ table.insert ( context . paths_to_load , path )
412+ end
413+ else
414+ log . error ( " error creating item for " , path )
415415 end
416- else
417- log .error (" error creating item for " , path )
418416 end
419417 end
418+ uv .fs_closedir (dir )
419+ else
420+ log .error (" Error opening dir:" , err )
420421 end
421- uv .fs_closedir (dir )
422422
423423 local next_path = dir_complete (context , path_to_scan )
424424 if next_path then
0 commit comments