@@ -26,7 +26,7 @@ import (
2626type PackType struct {
2727 xml.PdscTag
2828
29- //IsLocallySourced tells whether the pack's source is local or an HTTP URL
29+ // IsLocallySourced tells whether the pack's source is local or an HTTP URL
3030 IsLocallySourced bool
3131
3232 // IsPublic tells whether the pack exists in the public index or not
@@ -155,7 +155,7 @@ func preparePack(packPath string, toBeRemoved, forceLatest, noLocal, nometa bool
155155
156156 if pack .isPackID && nometa {
157157 if meta , found := utils .SemverHasMeta (pack .Version ); found {
158- return pack , fmt .Errorf ("%w: %q. Expected vendor.pack. version" , errs .ErrBadPackVersion , meta )
158+ return pack , fmt .Errorf ("%w: %q. Expected vendor%s. version" , errs .ErrBadPackVersion , meta , utils . PackExtension )
159159 }
160160 }
161161
@@ -208,8 +208,7 @@ func (p *PackType) fetch(timeout int) error {
208208 return nil
209209}
210210
211- // validate ensures the pack is legit and it has all minimal requirements
212- // to be installed.
211+ // validate ensures the pack is legit and it has all minimal requirements to be installed.
213212func (p * PackType ) validate () error {
214213 log .Debug ("Validating pack" )
215214 var err error
@@ -222,15 +221,15 @@ func (p *PackType) validate() error {
222221
223222 // Ensure all file paths do not contain ".."
224223 if strings .Contains (file .Name , ".." ) {
225- if ext == PdscExtension {
224+ if ext == utils . PdscExtension {
226225 log .Errorf ("File %q invalid file path" , file .Name )
227226 return errs .ErrInvalidFilePath
228227 } else {
229228 return errs .ErrInsecureZipFileName
230229 }
231230 }
232231
233- if ext == PdscExtension {
232+ if ext == utils . PdscExtension {
234233 // Check if pack was compressed in a subfolder
235234 subfoldersCount := strings .Count (file .Name , "/" ) + strings .Count (file .Name , "\\ " )
236235 if subfoldersCount > 1 {
@@ -239,7 +238,7 @@ func (p *PackType) validate() error {
239238 tmpFileName := filepath .Base (file .Name ) // normalize file name
240239 if ! strings .EqualFold (tmpFileName , myPdscFileName ) {
241240 if err != nil {
242- log .Warnf ("Pack %q contains an additional .pdsc file in a deeper subfolder, this may cause issues" , p .path )
241+ log .Warnf ("Pack %q contains an additional %s file in a deeper subfolder, this may cause issues" , p .path , utils . PdscExtension )
243242 }
244243 return fmt .Errorf ("%q: %w" , file .Name , errs .ErrPdscWrongName )
245244 }
@@ -259,7 +258,7 @@ func (p *PackType) validate() error {
259258
260259 if err != nil {
261260 if len (validPdscFiles ) > 0 {
262- log .Warnf ("Pack %q contains an additional .pdsc file in a deeper subfolder, this may cause issues" , p .path )
261+ log .Warnf ("Pack %q contains an additional %s file in a deeper subfolder, this may cause issues" , p .path , utils . PdscExtension )
263262 } else {
264263 return err
265264 }
@@ -346,6 +345,13 @@ func (p *PackType) purge() (bool, error) {
346345 return false , err
347346 }
348347
348+ cTag := xml.CacheTag {Vendor : p .Vendor , Name : p .Name , Version : p .Version }
349+ if err = Installation .PublicCacheIndexXML .RemovePdsc (cTag ); err == nil {
350+ webFile := Installation .WebDir + "/" + p .VName () + utils .PdscExtension
351+ files = append (files , webFile ) // also add pdsc file in .Web
352+ }
353+ _ = Installation .PublicCacheIndexXML .Write ()
354+
349355 log .Debugf ("Files to be purged \" %v\" " , files )
350356 if len (files ) == 0 {
351357 log .Infof ("pack %s.%s already removed from %s" , p .path , p .Version , Installation .DownloadDir )
@@ -763,17 +769,17 @@ func (p *PackType) PackIDWithVersion() string {
763769
764770// PackFileName returns a string with how the pack file name would be: Vendor.PackName.x.y.z.pack
765771func (p * PackType ) PackFileName () string {
766- return p .PackIDWithVersion () + PackExtension
772+ return p .PackIDWithVersion () + utils . PackExtension
767773}
768774
769775// PdscFileName returns a string with how the pack's pdsc file name would be: Vendor.PackName.pdsc
770776func (p * PackType ) PdscFileName () string {
771- return p .PackID () + PdscExtension
777+ return p .PackID () + utils . PdscExtension
772778}
773779
774780// PdscFileNameWithVersion returns a string with how the pack's pdsc file name would be: Vendor.PackName.x.y.z.pdsc
775781func (p * PackType ) PdscFileNameWithVersion () string {
776- return p .PackIDWithVersion () + PdscExtension
782+ return p .PackIDWithVersion () + utils . PdscExtension
777783}
778784
779785// GetVersion makes sure to get the latest version for the pack
0 commit comments