usmannasir / cyberpanel

Cyber Panel - The hosting control panel for OpenLiteSpeed
GNU General Public License v3.0
1.56k stars 602 forks source link

Websites List Shows 1MB instead of real disk space #459

Closed myst3k closed 3 years ago

myst3k commented 4 years ago

Opened for tracking

457:websiteFunctions/website.py: diskUsed = '1MB' ## to be fixed later

meramsey commented 3 years ago

So this issue could be addressed by the below steps to be fast and efficient.

I believe the above things should solve this issue and also not cause other issues. This is similar in how other control panels handle disk quota calculations via a cron and the usage reflected in the panel is always from the cached results of last cron.

meramsey commented 3 years ago

I also noticed the disk usage is calculated fine manually when viewing the website https://github.com/usmannasir/cyberpanel/blob/e1bb1bf72f17a788034c3fb2604c0129dc2494ef/plogical/website.py#L625

It looks like all that's actually needed is to store the usage from this function below https://github.com/usmannasir/cyberpanel/blob/e1bb1bf72f17a788034c3fb2604c0129dc2494ef/plogical/virtualHostUtilities.py#L1308-L1324

Into like the below file with just the usage in MB diskusagemeta = "/home/" + domainName + "/logs/diskquotameta"

Then we can setup the cron and code to reference cache and calculate percentage vs calculating total each time website list or website page is loaded

@usmannasir

usmannasir commented 3 years ago

I've scheduled the disk calculation to happen every day and save it in website config object. This should fix and speed web website load and search operations.

https://github.com/usmannasir/cyberpanel/commit/dd1c8b23514f3a0cb621b1a0cd36c0cc3907b552