feat: Add WebDAV support and tests

- Added basic WebDAV functionality for interacting with the
  underlying VFS.
- Created unit tests to verify WebDAV methods.
- Improved OurDBFS implementation by adding skip attribute to
  myvfs field.
This commit is contained in:
Mahmoud Emad
2025-02-20 16:50:11 +02:00
parent f08af0e2c5
commit 296cb9adf5
3 changed files with 43 additions and 1 deletions

View File

@@ -11,7 +11,7 @@ pub mut:
metadata Metadata // Metadata from models_common.v
children []u32 // List of child entry IDs (instead of actual entries)
parent_id u32 // ID of parent directory (0 for root)
myvfs &OurDBFS @[skip]
myvfs &OurDBFS @[str: skip]
}
pub fn (mut self Directory) save() ! {

View File

@@ -0,0 +1,41 @@
import freeflowuniverse.herolib.vfs.webdav
import freeflowuniverse.herolib.vfs.vfsnested
import freeflowuniverse.herolib.vfs.vfscore
import freeflowuniverse.herolib.vfs.vfsourdb
import os
fn test_logic() ! {
println('Testing OurDB VFS Logic to WebDAV Server...')
// Create test directories
test_data_dir := os.join_path(os.temp_dir(), 'vfsourdb_test_data')
test_meta_dir := os.join_path(os.temp_dir(), 'vfsourdb_test_meta')
os.mkdir_all(test_data_dir)!
os.mkdir_all(test_meta_dir)!
defer {
os.rmdir_all(test_data_dir) or {}
os.rmdir_all(test_meta_dir) or {}
}
// Create VFS instance; lower level VFS Implementations that use OurDB
mut vfs1 := vfsourdb.new(test_data_dir, test_meta_dir)!
mut high_level_vfs := vfsnested.new()
// Nest OurDB VFS instances at different paths
high_level_vfs.add_vfs('/', vfs1) or { panic(err) }
// Test directory listing
entries := high_level_vfs.dir_list('/')!
assert entries.len == 1 // Data directory
println('entries: ${entries}')
// // Check if dir is existing
// assert high_level_vfs.exists('/') == true
// // Check if dir is not existing
// assert high_level_vfs.exists('/data') == true
}

View File

@@ -214,6 +214,7 @@ fn (mut app App) mkcol(path string) vweb.Result {
@['/:path...'; propfind]
fn (mut app App) propfind(path string) vweb.Result {
println('path: ${path}')
if !app.vfs.exists(path) {
return app.not_found()
}