Skip to content

Commit

Permalink
Merge pull request #3 from Peefy/kcl-plugin-go-install-err-deal
Browse files Browse the repository at this point in the history
refactor: add kcl plugin go embed instal error dealing.
  • Loading branch information
NeverRaR authored Feb 22, 2023
2 parents b01d449 + 1873d2d commit cdf4d94
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions a_embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package kcl_plugin

import (
"embed"
"errors"
"io/fs"
"os"
"path/filepath"
Expand All @@ -17,7 +18,14 @@ var PluginFS embed.FS

func InstallPlugins(root string) error {
embedFS := PluginFS
os.MkdirAll(root, 0777)
err := os.MkdirAll(root, 0777)
// If permission denied, ignore it.
if errors.Is(err, fs.ErrPermission) {
return nil
}
if err != nil {
return err
}
return fs.WalkDir(embedFS, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
Expand All @@ -29,7 +37,6 @@ func InstallPlugins(root string) error {
if err := os.MkdirAll(filepath.Dir(abspath), 0777); err != nil {
_ = err
}

data, err := fs.ReadFile(embedFS, path)
if err != nil {
return err
Expand Down

0 comments on commit cdf4d94

Please sign in to comment.