Skip to content

Commit

Permalink
fix: windows package
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Dec 18, 2024
1 parent 4b347b7 commit 2efe881
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions internal/core/bundle_packager/memory_zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"archive/zip"
"bytes"
"io"
"path/filepath"
"strings"

"github.com/langgenius/dify-plugin-daemon/internal/types/entities/bundle_entities"
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/core/plugin_manager/remote_manager/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/core/plugin_packager/decoder/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 2efe881

Please sign in to comment.