Skip to content

Commit

Permalink
chore(server): add logs to plugin download from marketplace
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Jan 12, 2023
1 parent a1664d0 commit 436b689
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/internal/usecase/interactor/plugin_common.go
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/reearth/reearth/server/pkg/id"
"github.com/reearth/reearth/server/pkg/plugin"
"github.com/reearth/reearth/server/pkg/plugin/pluginpack"
"github.com/reearth/reearthx/log"
"github.com/reearth/reearthx/rerror"
)

Expand All @@ -21,19 +22,31 @@ type pluginCommon struct {
}

func (i *pluginCommon) SavePluginPack(ctx context.Context, p *pluginpack.Package) error {
read := false
id := p.Manifest.Plugin.ID()

for {
f, err := p.Files.Next()
if err != nil {
log.Errorf("failed to read a plugin file (%s): %s", id, err)
return interfaces.ErrInvalidPluginPackage
}

if f == nil {
break
}

read = true
if err := i.file.UploadPluginFile(ctx, p.Manifest.Plugin.ID(), f); err != nil {
return rerror.ErrInternalBy(err)
}
}

if !read {
log.Errorf("no plugin files (%s)", id)
return interfaces.ErrInvalidPluginPackage
}

// save plugin and property schemas
if ps := p.Manifest.PropertySchemas(); len(ps) > 0 {
if err := i.propertySchemaRepo.SaveAll(ctx, ps); err != nil {
Expand Down

0 comments on commit 436b689

Please sign in to comment.