0

We are using directory-tree npm to read all the directories and sub directories(subdirectories having 15000 multiple subdirectories)

Used Code:

const dirTree = require("directory-tree");

const allDirectories = dirTree('./test'); //It is taking 30minutes time to read all subdirectories

we need to show all the directories and subdirectories within 10s otherwise i have to terminated current http request and show timeout error.

The result : if the request taking more then 10s throw error

like, res.send({msg:"Reading all the directories taking too much time."});

Thanks

Reena
  • 1
  • 1
  • The library has a `depth` parameter. Perhaps you could lazy load the deeper subdirectories after the initial low depth request – K Scandrett Dec 09 '22 at 04:12
  • I don't have a option to define the depth need to show all levels of subdirectories – Reena Dec 09 '22 at 04:40

1 Answers1

0

You can run the code once with all the information about the tree structure and save it in some .txt file. Whenever you add/delete/update directories and subdirectories you also make an edit to this new .txt file. So you can return the contents of .txt files within the 10 seconds.

vnikonov_63
  • 191
  • 12
  • we need to take folders details in live we don't know when the users actually add new folders and delete old folders.suppose that is taking too much time throw timeout error also fine. – Reena Dec 09 '22 at 06:09