mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-11-25 11:29:29 +08:00
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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user