Browse Source

fix: plugins are not installed when plugin-daemon is restarted and plugins are stored on s3 (#36)

Masashi Tomooka 4 months ago
parent
commit
2db4e277ea

+ 0 - 9
internal/core/plugin_manager/media_transport/installed_bucket.go

@@ -48,15 +48,6 @@ func (b *InstalledBucket) Get(
 
 
 // List lists all the plugins in the installed bucket
 // List lists all the plugins in the installed bucket
 func (b *InstalledBucket) List() ([]plugin_entities.PluginUniqueIdentifier, error) {
 func (b *InstalledBucket) List() ([]plugin_entities.PluginUniqueIdentifier, error) {
-	// check if the patch exists
-	exists, err := b.oss.Exists(b.installedPath)
-	if err != nil {
-		return nil, err
-	}
-	if !exists {
-		return []plugin_entities.PluginUniqueIdentifier{}, nil
-	}
-
 	paths, err := b.oss.List(b.installedPath)
 	paths, err := b.oss.List(b.installedPath)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err

+ 10 - 2
internal/oss/local/local_storage.go

@@ -57,10 +57,18 @@ func (l *LocalStorage) State(key string) (oss.OSSState, error) {
 }
 }
 
 
 func (l *LocalStorage) List(prefix string) ([]oss.OSSPath, error) {
 func (l *LocalStorage) List(prefix string) ([]oss.OSSPath, error) {
-	prefix = filepath.Join(l.root, prefix)
 	paths := make([]oss.OSSPath, 0)
 	paths := make([]oss.OSSPath, 0)
+	// check if the patch exists
+	exists, err := l.Exists(prefix)
+	if err != nil {
+		return nil, err
+	}
+	if !exists {
+		return paths, nil
+	}
+	prefix = filepath.Join(l.root, prefix)
 
 
-	err := filepath.WalkDir(prefix, func(path string, d fs.DirEntry, err error) error {
+	err = filepath.WalkDir(prefix, func(path string, d fs.DirEntry, err error) error {
 		if err != nil {
 		if err != nil {
 			return err
 			return err
 		}
 		}