feat: Improve VFS handling and authentication middleware

- Remove unnecessary debug print statements in VFS and WebDAV
  middleware for cleaner code.
- Fix a bug in `OurDBVFS.exists` to correctly handle root and
  current directory paths.
- Enhance `OurDBVFS.get_entry` to handle '.' path correctly.
- Improve WebDAV authentication middleware to gracefully handle
  unauthenticated requests.
This commit is contained in:
Mahmoud Emad
2025-02-23 14:33:18 +02:00
parent 0d96c5fc65
commit aeeacc877b
2 changed files with 4 additions and 4 deletions

View File

@@ -90,7 +90,6 @@ pub fn (mut self OurDBVFS) dir_create(path string) !vfscore.FSEntry {
}
pub fn (mut self OurDBVFS) dir_list(path string) ![]vfscore.FSEntry {
println('listing ${path}')
mut dir := self.get_directory(path)!
mut entries := dir.children(false)!
mut result := []vfscore.FSEntry{}
@@ -113,7 +112,9 @@ pub fn (mut self OurDBVFS) dir_delete(path string) ! {
pub fn (mut self OurDBVFS) exists(path_ string) bool {
path := if !path_.starts_with('/') {
'/${path_}'
} else {path_}
} else {
path_
}
if path == '/' {
return true
}
@@ -178,7 +179,7 @@ pub fn (mut self OurDBVFS) destroy() ! {
}
fn (mut self OurDBVFS) get_entry(path string) !ourdb_fs.FSEntry {
if path == '/' || path == '' {
if path == '/' || path == '' || path == '.' {
return ourdb_fs.FSEntry(self.core.get_root()!)
}

View File

@@ -41,7 +41,6 @@ fn (app &App) auth_middleware(mut ctx Context) bool {
ctx.send_response_to_client('text', 'unauthorized')
return false
}
println('Successfully authenticated user. ${ctx.req}')
return true
}
ctx.res.set_status(.unauthorized)