Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Przybyl committed Oct 1, 2024
1 parent 9c3e7c1 commit 5abd048
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
9 changes: 4 additions & 5 deletions pkg/content/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (c Manager) Clean(path string) error {
if err := c.flattenFiles(path); err != nil {
return err
}
if err := c.DeleteFiles(path); err != nil {
if err := c.deleteFiles(path); err != nil {
return err
}
if err := deleteEmptyDirs(path); err != nil {
Expand Down Expand Up @@ -168,10 +168,9 @@ func (c Manager) cleanNamespaces(path string, lines []string) []string {
if groups == nil {
rootResult = append(rootResult, part)
} else {
flag := lo.SomeBy(lines, func(line string) bool {
if lo.SomeBy(lines, func(line string) bool {
return strings.Contains(line, groups[1]+":") || groups[1] == fileNamespace
})
if flag {
}) {
rootResult = append(rootResult, part)
}
}
Expand Down Expand Up @@ -232,7 +231,7 @@ func (c Manager) flattenFile(path string) error {
return os.Rename(path, dest)
}

func (c Manager) DeleteFiles(root string) error {
func (c Manager) deleteFiles(root string) error {
return eachFiles(root, func(path string) error {
return c.DeleteFile(path, func() bool {
return matchAnyRule(path, path, c.FilesDeleted)
Expand Down
10 changes: 5 additions & 5 deletions pkg/content_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (cm *ContentManager) Download(instance *Instance, localFile string, clean b
if err := cm.pullContent(instance, workDir, opts); err != nil {
return err
}
if err := cm.contentManager.Clean(filepath.Join(workDir, content.JCRRoot)); err != nil {
if err := cm.Clean(filepath.Join(workDir, content.JCRRoot)); err != nil {
return err
}
if err := content.Zip(workDir, localFile); err != nil {
Expand All @@ -65,7 +65,7 @@ func (cm *ContentManager) PullDir(instance *Instance, dir string, clean bool, re
return err
}
if replace {
if err := cm.contentManager.DeleteFiles(dir); err != nil {
if err := cm.contentManager.DeleteDir(dir); err != nil {
return err
}
}
Expand All @@ -74,7 +74,7 @@ func (cm *ContentManager) PullDir(instance *Instance, dir string, clean bool, re
return err
}
if clean {
if err := cm.contentManager.Clean(dir); err != nil {
if err := cm.Clean(dir); err != nil {
return err
}
}
Expand All @@ -98,7 +98,7 @@ func (cm *ContentManager) PullFile(instance *Instance, file string, clean bool,
return err
}
if clean {
if err := cm.contentManager.Clean(syncFile); err != nil {
if err := cm.Clean(syncFile); err != nil {
return err
}
}
Expand All @@ -112,7 +112,7 @@ func (cm *ContentManager) Push(instances []Instance, clean bool, opts PackageCre
return err
}
if clean {
if err := cm.contentManager.Clean(filepath.Join(workDir, content.JCRRoot)); err != nil {
if err := cm.Clean(filepath.Join(workDir, content.JCRRoot)); err != nil {
return err
}
}
Expand Down

0 comments on commit 5abd048

Please sign in to comment.