Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Using Perl for directory listing

by Discipulus (Canon)
on Sep 30, 2022 at 09:45 UTC ( [id://11147174]=note: print w/replies, xml ) Need Help??


in reply to Using Perl for directory listing

Hello htmanning,

> I have a large directory..

just a consideration: to compute stats for large directory is an expensive operation and I'd avoid to call it on the fly on a high traffic server.

More: the path you posted suggests a shared hosting scenario and if so most of the directories dont change in size frequently, if they do at all, so you will waste lot of disk access time to get small or no changes.

Depending on how much critical your needs are I'd follow one these options

A - put a cron scheduled during low traffic hours with a decent nice if needed to populate a static index with an header stating the time of the computation.

B - create a little demon to watch the main path (or the list of all subdirs) perhaps using File::ChangeNotify or similiar modules, and just recompute the size of the subdirectory modified.

PS rereading your post more carefully it seems you need to inspect just a subdirectory not the whole tree :) but, depending on how big and nested these subdirectoris are you may consider my approach anyway. For sure will be more fun to program it :P

If your are maintaining a shared hosting the demon approach has other pros: you can log size changes to spot huge and unwanted uploads, having more control in realtime on quotas. If you populate a static file or a database with your information realtime you will be able to query it or to navigate it in the way you need.

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Using Perl for directory listing
by cavac (Parson) on Oct 03, 2022 at 08:09 UTC

    Another option would be to regularly load the relevant data into a proper database with a background worker, then the frontend can access this data in milliseconds.

    PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11147174]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-25 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found