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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user