From bbd3a1c6bf38c12f6e7a761c937349dc4f047dbc Mon Sep 17 00:00:00 2001 From: zongz Date: Wed, 7 Aug 2024 18:12:26 +0800 Subject: [PATCH] fix: rm the generation of kcl.mod when compile virtual package Signed-off-by: zongz --- pkg/client/visitor.go | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/pkg/client/visitor.go b/pkg/client/visitor.go index b042eb01..6e4a5444 100644 --- a/pkg/client/visitor.go +++ b/pkg/client/visitor.go @@ -83,12 +83,6 @@ func (vpv *VirtualPkgVisitor) Visit(s *downloader.Source, v visitFunc) error { // After the visitFunc is executed, clean the virtual kcl.mod file. defer func() error { vKclModLockPath := filepath.Join(sourcePath, constants.KCL_MOD_LOCK) - if utils.DirExists(vKclModPath) { - err := os.RemoveAll(vKclModPath) - if err != nil { - return err - } - } if utils.DirExists(vKclModLockPath) { err := os.RemoveAll(vKclModLockPath) if err != nil { @@ -97,28 +91,16 @@ func (vpv *VirtualPkgVisitor) Visit(s *downloader.Source, v visitFunc) error { } return nil }() - initOpts := opt.InitOptions{ - Name: "vPkg_" + uuid.New().String(), - InitPath: sourcePath, - } - modfile := pkg.NewModFile(&initOpts) - logWriter := vpv.kpmcli.GetLogWriter() - vpv.kpmcli.SetLogWriter(nil) - err = vpv.kpmcli.createIfNotExist(modfile.GetModFilePath(), modfile.StoreModFile) - if err != nil { - return err - } - vpv.kpmcli.SetLogWriter(logWriter) } - - kclPkg, err := vpv.kpmcli.LoadPkgFromPath(sourcePath) - if err != nil { - return err + initOpts := opt.InitOptions{ + Name: "vPkg_" + uuid.New().String(), + InitPath: sourcePath, } + kpkg := pkg.NewKclPkg(&initOpts) // If the required files are present, proceed with the visitFunc - return v(kclPkg) + return v(&kpkg) } // RemoteVisitor is the visitor for visiting a remote package.