Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin install): copy executable by renaming instead of create file #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

c84c
Copy link

@c84c c84c commented May 17, 2022

Implements

Fix #121

Discussion

During refactoring on commit change plugin build mechanism the new flogo executable is created instead of renamed.

Linux system not allows to update a running executable resulting in error text file busy.

The PR insert a SwapFile function to allow replacement of running executable (Thanks to @fenollp and his gist)

Code references

Old renaming implementation on commits before change plugin build mechanism :

err = os.Rename(filepath.Join(cliCmdPath, cliExe), exe)

Actual implementation on master:
Executable copy:

err = util.Copy(filepath.Join(cliCmdPath, cliExe), exPath, false)

copyFile function

cli/util/file.go

Lines 131 to 143 in 5c3e1e3

var df *os.File
if df, err = os.Create(dst); err != nil {
return err
}
defer df.Close()
if err = os.Chmod(sf.Name(), srcInfo.Mode()); err != nil {
return err
}
if _, err = io.Copy(df, sf); err != nil {
return err
}

@c84c
Copy link
Author

c84c commented Jul 8, 2022

Have you planned when to merge the Pull Request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fail to install any CLI plugin
3 participants