it just works

This commit is contained in:
2023-01-12 12:05:53 +01:00
parent 4c7faa1b46
commit 733e2ab006
54 changed files with 336 additions and 3608 deletions

View File

@@ -4,6 +4,7 @@ import (
"os"
"path/filepath"
"github.com/marcopeocchi/yt-dlp-web-ui/server/config"
"github.com/marcopeocchi/yt-dlp-web-ui/server/internal"
"golang.org/x/sys/unix"
)
@@ -13,20 +14,20 @@ import (
// FreeSpace gets the available Bytes writable to download directory
func FreeSpace() (uint64, error) {
var stat unix.Statfs_t
wd, err := os.Getwd()
if err != nil {
return 0, err
}
unix.Statfs(wd+"/downloads", &stat)
unix.Statfs(config.Instance().GetConfig().DownloadPath, &stat)
return (stat.Bavail * uint64(stat.Bsize)), nil
}
func DirectoryTree(rootPath string) (*[]string, error) {
// Build a directory tree started from the specified path using DFS.
// Then return the flattened tree represented as a list.
func DirectoryTree() (*[]string, error) {
type Node struct {
path string
children []Node
}
rootPath := config.Instance().GetConfig().DownloadPath
stack := internal.Stack[Node]{
Nodes: make([]*internal.Node[Node], 5),
}