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