Skip to content

Commit

Permalink
Minors
Browse files Browse the repository at this point in the history
  • Loading branch information
krystian-panek-vmltech committed Apr 10, 2024
1 parent b1e43e1 commit b93f36c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions pkg/content/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ func (c Manager) AfterPullFile(path string) error {

func (c Manager) CleanDir(root string) error {
if !pathx.Exists(root) {
return fmt.Errorf("cannot clean directory as it does not exist: %s", root)
return fmt.Errorf("cannot clean directory as it does not exist '%s'", root)
}
log.Infof("cleaning directory %s", root)
log.Infof("cleaning directory '%s'", root)
if err := c.cleanDotContents(root); err != nil {
return err
}
Expand All @@ -92,15 +92,15 @@ func (c Manager) CleanDir(root string) error {
if err := deleteEmptyDirs(root); err != nil {
return err
}
log.Infof("cleaned %s directory", root)
log.Infof("cleaned directory '%s'", root)
return nil
}

func (c Manager) CleanFile(path string) error {
if !pathx.Exists(path) {
return fmt.Errorf("cannot clean file as it does not exist: %s", path)
}
log.Infof("cleaning file %s", path)
log.Infof("cleaning file '%s'", path)
if err := c.cleanDotContentFile(path); err != nil {
return err
}
Expand All @@ -110,7 +110,7 @@ func (c Manager) CleanFile(path string) error {
if err := deleteEmptyDirs(filepath.Dir(path)); err != nil {
return err
}
log.Infof("cleaned %s file", path)
log.Infof("cleaned file '%s'", path)
return nil
}

Expand Down Expand Up @@ -149,7 +149,7 @@ func (c Manager) cleanDotContentFile(path string) error {
return nil
}

log.Debugf("cleaning dot content file %s", path)
log.Infof("cleaning dot content file '%s'", path)
inputLines, err := readLines(path)
if err != nil {
return err
Expand Down Expand Up @@ -248,9 +248,9 @@ func (c Manager) flattenFile(path string) error {

dest := filepath.Dir(path) + ".xml"
if pathx.Exists(dest) {
log.Debugf("flattening file (override): %s", path)
log.Infof("flattening file (override) '%s'", path)
} else {
log.Debugf("flattening file: %s", path)
log.Infof("flattening file '%s'", path)
}
return os.Rename(path, dest)
}
Expand Down Expand Up @@ -279,15 +279,15 @@ func deleteDir(dir string) error {
if !pathx.Exists(dir) {
return nil
}
log.Debugf("deleting dir %s", dir)
log.Infof("deleting dir '%s'", dir)
return os.RemoveAll(dir)
}

func deleteFile(path string, allowedFunc func() bool) error {
if !pathx.Exists(path) || allowedFunc != nil && !allowedFunc() {
return nil
}
log.Debugf("deleting file %s", path)
log.Infof("deleting file '%s'", path)
return os.Remove(path)
}

Expand All @@ -308,7 +308,7 @@ func deleteEmptyDirs(root string) error {
return err
}
if len(entries) == 0 {
log.Debugf("deleting empty directory %s", root)
log.Infof("deleting empty directory '%s'", root)
if err = os.Remove(root); err != nil {
return err
}
Expand All @@ -320,7 +320,7 @@ func (c Manager) doParentsBackup(root string) error {
return eachParentFiles(root, func(parent string) error {
return eachFilesInDir(parent, func(path string) error {
if !strings.HasSuffix(path, ParentsBackupSuffix) {
log.Debugf("doing backup of parent file: %s", path)
log.Infof("doing backup of parent file '%s'", path)
if err := c.backupFile(path); err != nil {
return err
}
Expand All @@ -334,7 +334,7 @@ func (c Manager) doSiblingsBackup(file string) error {
dir := filepath.Dir(file)
return eachFilesInDir(dir, func(path string) error {
if path != file && !strings.HasSuffix(path, ParentsBackupSuffix) {
log.Debugf("doing backup of file: %s", path)
log.Infof("doing backup of file '%s'", path)
if err := c.backupFile(path); err != nil {
return err
}
Expand Down Expand Up @@ -367,7 +367,7 @@ func (c Manager) undoParentsBackup(root string) error {
return eachFilesInDir(parent, func(path string) error {
if strings.HasSuffix(path, ParentsBackupSuffix) {
origin := strings.TrimSuffix(path, ParentsBackupSuffix)
log.Debugf("undoing backup of parent file: %s", path)
log.Infof("undoing backup of parent file '%s'", path)
return os.Rename(path, origin)
}
return nil
Expand All @@ -380,7 +380,7 @@ func (c Manager) undoSiblingBackup(path string) error {
return eachFilesInDir(dir, func(path string) error {
if strings.HasSuffix(path, ParentsBackupSuffix) {
origin := strings.TrimSuffix(path, ParentsBackupSuffix)
log.Debugf("undoing backup of file: %s", path)
log.Infof("undoing backup of file '%s'", path)
return os.Rename(path, origin)
} else if strings.HasSuffix(path, ParentsBackupDirIndicator) {
return deleteFile(path, nil)
Expand Down

0 comments on commit b93f36c

Please sign in to comment.