Skip to content

Commit 59ac5e6

Browse files
authored
fix: fix uv offline set position (#644)
1 parent afad84d commit 59ac5e6

4 files changed

Lines changed: 54 additions & 11 deletions

File tree

cmd/server/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"context"
55

6+
"github.com/joho/godotenv"
67
"github.com/kelseyhightower/envconfig"
78
"github.com/langgenius/dify-plugin-daemon/internal/server"
89
"github.com/langgenius/dify-plugin-daemon/internal/types/app"
@@ -11,7 +12,7 @@ import (
1112

1213
func main() {
1314
var config app.Config
14-
15+
_ = godotenv.Load()
1516
err := envconfig.Process("", &config)
1617
if err != nil {
1718
log.Panic("error processing environment variables", "error", err)

internal/core/plugin_manager/packages.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import (
55
"fmt"
66
"os"
77
"strings"
8-
"time"
98

109
"github.com/langgenius/dify-plugin-daemon/internal/db"
1110
"github.com/langgenius/dify-plugin-daemon/internal/types/models"
1211
"github.com/langgenius/dify-plugin-daemon/pkg/entities/plugin_entities"
1312
"github.com/langgenius/dify-plugin-daemon/pkg/plugin_packager/decoder"
14-
"github.com/langgenius/dify-plugin-daemon/pkg/utils/cache"
1513
"github.com/langgenius/dify-plugin-daemon/pkg/utils/cache/helper"
1614
)
1715

@@ -59,9 +57,6 @@ func (p *PluginManager) SavePackage(
5957
return nil, err
6058
}
6159

62-
cacheKey := "manually_uploaded:" + plugin_unique_identifier.String()
63-
err = cache.Store(cacheKey, true, time.Second*10)
64-
6560
// create plugin if not exists (idempotent under concurrency)
6661
if _, err := db.GetOne[models.PluginDeclaration](
6762
db.Equal("plugin_unique_identifier", uniqueIdentifier.String()),

internal/service/plugin_decoder.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"io"
66
"mime/multipart"
7+
"time"
78

89
"github.com/gin-gonic/gin"
910
"github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager"
@@ -14,6 +15,7 @@ import (
1415
"github.com/langgenius/dify-plugin-daemon/pkg/entities/bundle_entities"
1516
"github.com/langgenius/dify-plugin-daemon/pkg/entities/plugin_entities"
1617
"github.com/langgenius/dify-plugin-daemon/pkg/plugin_packager/decoder"
18+
"github.com/langgenius/dify-plugin-daemon/pkg/utils/cache"
1719
"github.com/langgenius/dify-plugin-daemon/pkg/utils/cache/helper"
1820
)
1921

@@ -66,11 +68,8 @@ func UploadPluginPkg(
6668
verification = decoder.DefaultVerification()
6769
}
6870

69-
// if config.EnforceLanggeniusSignatures {
70-
// if isUnauthorizedLanggenius(declaration, verification) {
71-
// return exception.BadRequestError(ErrUnauthorizedLanggenius).ToResponse()
72-
// }
73-
// }
71+
cacheKey := "manually_uploaded:" + pluginUniqueIdentifier.String()
72+
err = cache.Store(cacheKey, true, time.Second*10)
7473

7574
return entities.NewSuccessResponse(map[string]any{
7675
"unique_identifier": pluginUniqueIdentifier,
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package service
2+
3+
import (
4+
"testing"
5+
6+
"github.com/langgenius/dify-plugin-daemon/pkg/entities/plugin_entities"
7+
)
8+
9+
func TestUploadPluginPkg_CacheKeyFormat(t *testing.T) {
10+
tests := []struct {
11+
name string
12+
pluginUniqueIdentifier plugin_entities.PluginUniqueIdentifier
13+
expectedKey string
14+
}{
15+
{
16+
name: "standard plugin identifier",
17+
pluginUniqueIdentifier: plugin_entities.PluginUniqueIdentifier("author/plugin@1.0.0"),
18+
expectedKey: "manually_uploaded:author/plugin@1.0.0",
19+
},
20+
{
21+
name: "plugin with version hash",
22+
pluginUniqueIdentifier: plugin_entities.PluginUniqueIdentifier("author/plugin@abc123def456"),
23+
expectedKey: "manually_uploaded:author/plugin@abc123def456",
24+
},
25+
{
26+
name: "plugin with special characters",
27+
pluginUniqueIdentifier: plugin_entities.PluginUniqueIdentifier("my-org/my-plugin@1.0.0-beta"),
28+
expectedKey: "manually_uploaded:my-org/my-plugin@1.0.0-beta",
29+
},
30+
{
31+
name: "langgenius gemini plugin",
32+
pluginUniqueIdentifier: plugin_entities.PluginUniqueIdentifier("langgenius/gemini@0.7.17"),
33+
expectedKey: "manually_uploaded:langgenius/gemini@0.7.17",
34+
},
35+
}
36+
37+
for _, tt := range tests {
38+
t.Run(tt.name, func(t *testing.T) {
39+
cacheKey := "manually_uploaded:" + tt.pluginUniqueIdentifier.String()
40+
41+
if cacheKey != tt.expectedKey {
42+
t.Errorf("cache key mismatch\n got: %s\nwant: %s", cacheKey, tt.expectedKey)
43+
}
44+
45+
t.Logf("✓ Cache key format correct: %s", cacheKey)
46+
})
47+
}
48+
}

0 commit comments

Comments
 (0)