refactor: Improve WebDAV VFS implementation

- Removed unnecessary dependencies and improved code structure in `webdav` module.
- Updated VFS configuration to use global VFS instance for WebDAV app.
- Renamed example VFS file to reflect WebDAV functionality.
- Removed redundant code and simplified app initialization.
- Used the vfs interface to interact with files and dirs.
This commit is contained in:
Mahmoud Emad
2025-02-19 22:57:15 +02:00
parent 33150846cc
commit f08af0e2c5
4 changed files with 5 additions and 12 deletions

View File

@@ -5,7 +5,7 @@ import freeflowuniverse.herolib.vfs.vfscore
// NestedVFS represents a VFS that can contain multiple nested VFS instances
pub struct NestedVFS {
mut:
vfs_map map[string]vfscore.VFSImplementation // Map of path prefixes to VFS implementations
vfs_map map[string]vfscore.VFSImplementation @[skip] // Map of path prefixes to VFS implementations
}
// new creates a new NestedVFS instance

View File

@@ -8,10 +8,9 @@ import freeflowuniverse.herolib.vfs.vfscore
struct App {
vweb.Context
user_db map[string]string @[required]
// root_dir pathlib.Path @[vweb_global]
pub mut:
lock_manager LockManager
vfs vfscore.VFSImplementation
vfs vfscore.VFSImplementation @[vweb_global]
server_port int
middlewares map[string][]vweb.Middleware
}
@@ -20,16 +19,13 @@ pub mut:
pub struct AppArgs {
pub mut:
server_port int = 8080
// root_dir string @[required]
user_db map[string]string @[required]
vfs vfscore.VFSImplementation
user_db map[string]string @[required]
vfs vfscore.VFSImplementation
}
pub fn new_app(args AppArgs) !&App {
// root_dir := pathlib.get_dir(path: args.root_dir, create: true)!
mut app := &App{
user_db: args.user_db.clone()
// root_dir: root_dir
user_db: args.user_db.clone()
server_port: args.server_port
vfs: args.vfs
}

View File

@@ -1,11 +1,8 @@
module webdav
import freeflowuniverse.herolib.core.pathlib
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.vfs.ourdb_fs
import encoding.xml
import net.urllib
import os
import vweb
@['/:path...'; options]