fix collection dependencies : install subparts of collection, even if the collec file itself exists (#101)

This commit is contained in:
Thibault "bui" Koechlin 2020-06-29 17:31:37 +02:00 committed by GitHub
parent 44076dd3d5
commit 02b2193d64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -574,6 +574,7 @@ func DisableItem(target Item, tdir string, hdir string, purge bool) (Item, error
} }
func EnableItem(target Item, tdir string, hdir string) (Item, error) { func EnableItem(target Item, tdir string, hdir string) (Item, error) {
var err error
parent_dir := filepath.Clean(tdir + "/" + target.Type + "/" + target.Stage + "/") parent_dir := filepath.Clean(tdir + "/" + target.Type + "/" + target.Stage + "/")
/*create directories if needed*/ /*create directories if needed*/
if target.Installed { if target.Installed {
@ -583,7 +584,8 @@ func EnableItem(target Item, tdir string, hdir string) (Item, error) {
if target.Local { if target.Local {
return target, fmt.Errorf("%s is local, won't enable", target.Name) return target, fmt.Errorf("%s is local, won't enable", target.Name)
} }
if target.UpToDate { /* if it's a collection, check sub-items even if the collection file itself is up-to-date */
if target.UpToDate && target.Type != COLLECTIONS {
log.Debugf("%s is installed and up-to-date, skip.", target.Name) log.Debugf("%s is installed and up-to-date, skip.", target.Name)
return target, nil return target, nil
} }
@ -594,7 +596,7 @@ func EnableItem(target Item, tdir string, hdir string) (Item, error) {
return target, fmt.Errorf("unable to create parent directories") return target, fmt.Errorf("unable to create parent directories")
} }
} }
if _, err := os.Lstat(parent_dir + "/" + target.FileName); os.IsNotExist(err) {
/*install sub-items if it's a collection*/ /*install sub-items if it's a collection*/
if target.Type == COLLECTIONS { if target.Type == COLLECTIONS {
var tmp = [][]string{target.Parsers, target.PostOverflows, target.Scenarios, target.Collections} var tmp = [][]string{target.Parsers, target.PostOverflows, target.Scenarios, target.Collections}
@ -614,6 +616,8 @@ func EnableItem(target Item, tdir string, hdir string) (Item, error) {
} }
} }
} }
if _, err := os.Lstat(parent_dir + "/" + target.FileName); os.IsNotExist(err) {
//tdir+target.RemotePath //tdir+target.RemotePath
srcPath, err := filepath.Abs(hdir + "/" + target.RemotePath) srcPath, err := filepath.Abs(hdir + "/" + target.RemotePath)
if err != nil { if err != nil {