Skip to content

Commit

Permalink
fix: fetching plugin model from CombinedGetPluginDeclaration shoud be…
Browse files Browse the repository at this point in the history
… invaild
  • Loading branch information
Yeuoly committed Nov 12, 2024
1 parent 26fd94e commit 4d64971
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions internal/utils/cache/helper/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"github.com/langgenius/dify-plugin-daemon/internal/utils/cache"
)

func CombinedGetPluginDeclaration(plugin_unique_identifier plugin_entities.PluginUniqueIdentifier) (*plugin_entities.PluginDeclaration, error) {
func CombinedGetPluginDeclaration(
plugin_unique_identifier plugin_entities.PluginUniqueIdentifier,
) (*plugin_entities.PluginDeclaration, error) {
return cache.AutoGetWithGetter(
plugin_unique_identifier.String(),
func() (*plugin_entities.PluginDeclaration, error) {
Expand All @@ -18,18 +20,11 @@ func CombinedGetPluginDeclaration(plugin_unique_identifier plugin_entities.Plugi
return nil, err
}

if err == nil {
return &declaration.Declaration, nil
}

model, err := db.GetOne[models.Plugin](
db.Equal("plugin_unique_identifier", plugin_unique_identifier.String()),
)
if err != nil {
return nil, err
}

return &model.Declaration, nil
return &declaration.Declaration, nil
},
)
}

0 comments on commit 4d64971

Please sign in to comment.