fix(directlink): direct link should not be accessible if the parent file is in trash bin (#2415)

This commit is contained in:
Aaron Liu
2025-05-29 09:42:22 +08:00
parent ec53769e33
commit 65095855c1
7 changed files with 62 additions and 41 deletions

View File

@@ -197,6 +197,25 @@ func (b *baseNavigator) walkNext(ctx context.Context, root *File, next string, i
return newFile(root, child), nil
}
// findRoot finds the root folder of the given child.
func (b *baseNavigator) findRoot(ctx context.Context, child *File) (*File, error) {
root := child
for {
newRoot, err := b.walkUp(ctx, root)
if err != nil {
if !ent.IsNotFound(err) {
return nil, err
}
break
}
root = newRoot
}
return root, nil
}
func (b *baseNavigator) walkUp(ctx context.Context, child *File) (*File, error) {
parent, err := b.fileClient.GetParentFile(ctx, child.Model, false)
if err != nil {