Skip to content

Commit 3e9f255

Browse files
authored
improve plugin storage path (#4298)
Signed-off-by: Min Min <jamsman94@gmail.com>
1 parent be60cd4 commit 3e9f255

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

  • pkg/microservice/aslan/core/system/service

pkg/microservice/aslan/core/system/service/plugin.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func CreatePluginWithFile(userName string, m *commonmodels.Plugin, fileHeader *m
9292
return e.ErrCreateIDPPlugin.AddErr(err)
9393
}
9494

95-
objectKey := store.GetObjectPath(getPluginFilePath(m.Name, fileHeader.Filename))
95+
objectKey := store.GetObjectPath(getPluginFilePath(m.Identifier, fileHeader.Filename))
9696
if err := client.Upload(store.Bucket, tempPath, objectKey); err != nil {
9797
log.Errorf("failed to upload file to s3, err: %v", err)
9898
return e.ErrCreateIDPPlugin.AddErr(err)
@@ -146,7 +146,7 @@ func UpdatePluginWithFile(userName string, id string, m *commonmodels.Plugin, fi
146146
log.Errorf("failed to create s3 client, err: %v", err)
147147
return e.ErrUpdateIDPPlugin.AddErr(err)
148148
}
149-
objectKey := store.GetObjectPath(getPluginFilePath(m.Name, fileHeader.Filename))
149+
objectKey := store.GetObjectPath(getPluginFilePath(m.Identifier, fileHeader.Filename))
150150
if err := client.Upload(store.Bucket, tempPath, objectKey); err != nil {
151151
log.Errorf("failed to upload file to s3, err: %v", err)
152152
return e.ErrUpdateIDPPlugin.AddErr(err)
@@ -173,7 +173,7 @@ func GetPluginFile(id string, log *zap.SugaredLogger) (string, string, error) {
173173
}
174174

175175
// build cache path under local workspace
176-
cachePath := filepath.Join(config.S3StoragePath(), "plugins", p.Name, p.FileName)
176+
cachePath := filepath.Join(config.S3StoragePath(), "plugins", p.Identifier, p.FileName)
177177
if err := os.MkdirAll(filepath.Dir(cachePath), 0755); err != nil {
178178
return "", "", err
179179
}
@@ -207,8 +207,8 @@ func GetPluginFile(id string, log *zap.SugaredLogger) (string, string, error) {
207207
return cachePath, p.FileName, nil
208208
}
209209

210-
func getPluginFilePath(name, fileName string) string {
211-
return filepath.Join("plugins", name, fileName)
210+
func getPluginFilePath(identifier, fileName string) string {
211+
return filepath.Join("plugins", identifier, fileName)
212212
}
213213

214214
func verifyFileHash(path string, expected string) bool {

0 commit comments

Comments
 (0)