feat(url-tree): implement the Put interface to support adding links directly to the UrlTree on the web side (#8312)

* feat(url-tree)支持PUT

* feat(url-tree) UrlTree更新时,需要将路径和内容分割 #8303

* fix: stdpath.Join call

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Andy Hsu <i@nn.ci>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Lee CQ
2025-04-12 17:27:56 +08:00
committed by GitHub
parent f0b1aeaf8d
commit 88abb323cb
3 changed files with 54 additions and 1 deletions

View File

@@ -243,7 +243,25 @@ func (d *Urls) PutURL(ctx context.Context, dstDir model.Obj, name, url string) (
}
func (d *Urls) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) error {
return errs.UploadNotSupported
if !d.Writable {
return errs.PermissionDenied
}
d.mutex.Lock()
defer d.mutex.Unlock()
node := GetNodeFromRootByPath(d.root, dstDir.GetPath()) // parent
if node == nil {
return errs.ObjectNotFound
}
if node.isFile() {
return errs.NotFolder
}
file, err := parseFileLine(stream.GetName(), d.HeadSize)
if err != nil {
return err
}
node.Children = append(node.Children, file)
d.updateStorage()
return nil
}
func (d *Urls) updateStorage() {