예제 #1
0
func (cmd *PluginInstall) tryDownloadPluginBinaryfromGivenPath(pluginSourceFilepath string, downloader fileutils.Downloader) string {
	size, filename, err := downloader.DownloadFile(pluginSourceFilepath)

	if err != nil {
		cmd.ui.Failed(fmt.Sprintf(T("Download attempt failed: {{.Error}}\n\nUnable to install, plugin is not available from the given url.", map[string]interface{}{"Error": err.Error()})))
	}

	cmd.ui.Say(fmt.Sprintf("%d "+T("bytes downloaded")+"...", size))

	executablePath := filepath.Join(downloader.SavePath(), filename)
	os.Chmod(executablePath, 0700)

	return executablePath
}