From 2efe881e5b141ad5706513bb563dd8dbcaefb346 Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Wed, 18 Dec 2024 21:56:59 +0800 Subject: [PATCH] fix: windows package --- internal/core/bundle_packager/memory_zip.go | 5 +++-- internal/core/plugin_manager/remote_manager/server_test.go | 2 +- internal/core/plugin_packager/decoder/helper.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/core/bundle_packager/memory_zip.go b/internal/core/bundle_packager/memory_zip.go index 5e66f80..3a2e596 100644 --- a/internal/core/bundle_packager/memory_zip.go +++ b/internal/core/bundle_packager/memory_zip.go @@ -4,6 +4,7 @@ import ( "archive/zip" "bytes" "io" + "path/filepath" "strings" "github.com/langgenius/dify-plugin-daemon/internal/types/entities/bundle_entities" @@ -63,7 +64,7 @@ func NewMemoryZipBundlePackager(zipFile []byte) (*MemoryZipBundlePackager, error // walk through the zip file and load the assets for _, file := range zipReader.File { // if file starts with "_assets/" - if strings.HasPrefix(file.Name, "_assets/") { + if strings.HasPrefix(file.Name, "_assets"+string(filepath.Separator)) { // load the asset asset, err := file.Open() if err != nil { @@ -77,7 +78,7 @@ func NewMemoryZipBundlePackager(zipFile []byte) (*MemoryZipBundlePackager, error } // trim the prefix "_assets/" - assetName := strings.TrimPrefix(file.Name, "_assets/") + assetName := strings.TrimPrefix(file.Name, "_assets"+string(filepath.Separator)) packager.assets[assetName] = bytes.NewBuffer(assetBytes) } diff --git a/internal/core/plugin_manager/remote_manager/server_test.go b/internal/core/plugin_manager/remote_manager/server_test.go index 71bda72..4a45c22 100644 --- a/internal/core/plugin_manager/remote_manager/server_test.go +++ b/internal/core/plugin_manager/remote_manager/server_test.go @@ -49,7 +49,7 @@ func preparePluginServer(t *testing.T) (*RemotePluginServer, uint16) { PluginRemoteInstallingPort: port, PluginRemoteInstallingMaxConn: 1, PluginRemoteInstallServerEventLoopNums: 8, - }, media_manager.NewAssetsBucket(oss, "./assets", 10)), port + }, media_manager.NewAssetsBucket(oss, "assets", 10)), port } // TestLaunchAndClosePluginServer tests the launch and close of the plugin server diff --git a/internal/core/plugin_packager/decoder/helper.go b/internal/core/plugin_packager/decoder/helper.go index 83c224f..73e041c 100644 --- a/internal/core/plugin_packager/decoder/helper.go +++ b/internal/core/plugin_packager/decoder/helper.go @@ -266,7 +266,7 @@ func (p *PluginDecoderHelper) Assets(decoder PluginDecoder) (map[string][]byte, return nil, err } // trim _assets - file, _ = strings.CutPrefix(file, "_assets/") + file, _ = strings.CutPrefix(file, "_assets"+string(filepath.Separator)) assets[file] = content }