marcopeocchi / yt-dlp-web-ui

A terrible web ui and RPC server for yt-dlp. Designed to be self-hosted.
GNU General Public License v3.0
820 stars 85 forks source link

wrong disk usage #14

Closed deluxghost closed 1 year ago

deluxghost commented 1 year ago

https://github.com/marcopeocchi/yt-dlp-web-ui/blob/8ee9710fe2d091f6d09a2d4e3064b156bdd3e3b5/server/src/utils/procUtils.ts#L47

Looks like you always fetch the last line of df output, which doesn't make any sense, for example:

 # df -P -h
Filesystem                Size      Used Available Capacity Mounted on
overlay                  15.9T    103.7G     15.0T   1% /
tmpfs                    64.0M         0     64.0M   0% /dev
tmpfs                     7.8G         0      7.8G   0% /sys/fs/cgroup
shm                      64.0M         0     64.0M   0% /dev/shm
/dev/sda3                15.9T    103.7G     15.0T   1% /etc/resolv.conf
/dev/sda3                15.9T    103.7G     15.0T   1% /etc/hostname
/dev/sda3                15.9T    103.7G     15.0T   1% /etc/hosts
/dev/sda3                15.9T    103.7G     15.0T   1% /usr/src/yt-dlp-webui/downloads
tmpfs                     7.8G         0      7.8G   0% /proc/acpi
tmpfs                    64.0M         0     64.0M   0% /proc/kcore
tmpfs                    64.0M         0     64.0M   0% /proc/keys
tmpfs                    64.0M         0     64.0M   0% /proc/timer_list
tmpfs                    64.0M         0     64.0M   0% /proc/sched_debug
tmpfs                     7.8G         0      7.8G   0% /proc/scsi
tmpfs                     7.8G         0      7.8G   0% /sys/firmware

you will get 7.8G

marcopeocchi commented 1 year ago

You're absolute right, it doesn't make sense. It's maybe an heritage

This is correct and i'm commiting the fix.

exec(`df -h ${path} | tail -1 | awk '{print $4}'`, (_, stdout) => {
    socket.emit(message, stdout)
})

Where path is the download directory by default.