mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Don't ignore assets in home dir if system assets exist
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
parent
fe18b1fce9
commit
1e38b5d904
@ -222,16 +222,20 @@ func getAssetAndDir(dataDir string) (string, string) {
|
|||||||
// extract checks for and if necessary unpacks the bindata archive, returning the unique path
|
// extract checks for and if necessary unpacks the bindata archive, returning the unique path
|
||||||
// to the extracted bindata asset.
|
// to the extracted bindata asset.
|
||||||
func extract(dataDir string) (string, error) {
|
func extract(dataDir string) (string, error) {
|
||||||
// first look for global asset folder so we don't create a HOME version if not needed
|
// check if content already exists in requested data-dir
|
||||||
_, dir := getAssetAndDir(datadir.DefaultDataDir)
|
asset, dir := getAssetAndDir(dataDir)
|
||||||
if _, err := os.Stat(filepath.Join(dir, "bin", "k3s")); err == nil {
|
if _, err := os.Stat(filepath.Join(dir, "bin", "k3s")); err == nil {
|
||||||
return dir, nil
|
return dir, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
asset, dir := getAssetAndDir(dataDir)
|
// check if content exists in default path as a fallback, prior
|
||||||
// check if target content already exists
|
// to extracting. This will prevent re-extracting into the user's home
|
||||||
if _, err := os.Stat(filepath.Join(dir, "bin", "k3s")); err == nil {
|
// dir if the assets already exist in the default path.
|
||||||
return dir, nil
|
if dataDir != datadir.DefaultDataDir {
|
||||||
|
_, defaultDir := getAssetAndDir(datadir.DefaultDataDir)
|
||||||
|
if _, err := os.Stat(filepath.Join(defaultDir, "bin", "k3s")); err == nil {
|
||||||
|
return defaultDir, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// acquire a data directory lock
|
// acquire a data directory lock
|
||||||
|
Loading…
Reference in New Issue
Block a user