enable item when they have been added to a collection since previous release (#599)

Co-authored-by: AlteredCoder <AlteredCoder>
This commit is contained in:
AlteredCoder 2021-02-04 17:17:51 +01:00 committed by GitHub
parent 359a9cb8ce
commit 50ee846e87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -94,10 +94,19 @@ func DownloadLatest(cscli *csconfig.CscliCfg, target Item, overwrite bool) (Item
return target, errors.Wrap(err, fmt.Sprintf("while downloading %s", val.Name))
}
}
hubIdx[ptrtype][p], err = DownloadItem(cscli, val, overwrite)
item, err := DownloadItem(cscli, val, overwrite)
if err != nil {
return target, errors.Wrap(err, fmt.Sprintf("while downloading %s", val.Name))
}
// We need to enable an item when it has been added to a collection since latest release of the collection.
// We check if val.Downloaded is false because maybe the item has been disabled by the user.
if !item.Installed && !val.Downloaded {
if item, err = EnableItem(cscli, item); err != nil {
return target, errors.Wrapf(err, "enabling '%s'", item.Name)
}
}
hubIdx[ptrtype][p] = item
} else {
return target, fmt.Errorf("required %s %s of %s doesn't exist, abort", ptrtype, p, target.Name)
}