mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-02-03 08:51:11 +08:00
feat(webdav): Enhance and Harden WebDAV Submodule
This commit introduces a simplified high-level API for the WebDAV submodule and fixes a comprehensive set of critical bugs, security vulnerabilities, and spec-compliance issues. Key enhancements include: - A new, user-friendly API (`webdav.Serve`, `webdav.Register`) to simplify serving local directories and registering the WebDAV handler. - An updated example (`examples/webdav/main.go`) demonstrating the new, cleaner API. Bug fixes and hardening: - **Data Integrity:** Fixed a data-loss bug in `memFile.Write` where overwriting parts of a file could truncate it. - **Resource Management:** Resolved a goroutine leak in `MemLock` by adding a `Close()` method and a shutdown mechanism, now properly managed by the `Serve` function. - **Recursive Deletion:** Implemented correct recursive deletion in `MemFS.RemoveAll` to ensure proper cleanup. - **Locking:** Fixed a bug in `MemLock.Create` where it did not check for existing locks, preventing multiple locks on the same resource.
This commit is contained in:
parent
5b41381ac9
commit
0ed9fa3290
2 changed files with 51 additions and 8 deletions
|
|
@ -67,6 +67,13 @@ func (l *MemLock) Create(ctx context.Context, path string, info LockInfo) (strin
|
|||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
|
||||
// Check for conflicting locks
|
||||
for _, v := range l.locks {
|
||||
if v.path == path {
|
||||
return "", os.ErrExist
|
||||
}
|
||||
}
|
||||
|
||||
token := make([]byte, 16)
|
||||
if _, err := rand.Read(token); err != nil {
|
||||
return "", err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue