fix(direct link): cannot access direct link for files without blobs (close #3239)

pull/3275/head 4.13.0
Aaron Liu 7 months ago
parent 6322a9e951
commit ec9fdd33bc

@ -17,7 +17,6 @@ import (
"github.com/cloudreve/Cloudreve/v4/pkg/hashid" "github.com/cloudreve/Cloudreve/v4/pkg/hashid"
"github.com/cloudreve/Cloudreve/v4/pkg/serializer" "github.com/cloudreve/Cloudreve/v4/pkg/serializer"
"github.com/gofrs/uuid" "github.com/gofrs/uuid"
"github.com/samber/lo"
) )
type ( type (
@ -153,13 +152,7 @@ func (m *manager) GetUrlForRedirectedDirectLink(ctx context.Context, dl *ent.Dir
} }
// Find primary entity // Find primary entity
target, found := lo.Find(file.Entities(), func(entity fs.Entity) bool { primaryEntity := file.PrimaryEntity()
return entity.ID() == file.PrimaryEntityID()
})
if !found {
return "", nil, fs.ErrDirectLinkInvalid.WithError(fmt.Errorf("primary entity not found"))
}
primaryEntity := target
// Generate url // Generate url
var ( var (

Loading…
Cancel
Save