ソースを参照

fix: windows package

Yeuoly 7 ヶ月 前
コミット
2efe881e5b

+ 3 - 2
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)
 		}

+ 1 - 1
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

+ 1 - 1
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
 	}