Skip to content

Commit

Permalink
Merge pull request #35 from brian-bice/fix-symlink-list-on-external-l…
Browse files Browse the repository at this point in the history
…inks

fix symlink list on external links
  • Loading branch information
brian-bice authored Apr 4, 2022
2 parents 0a0cbb7 + 7a94df8 commit fb9f8dd
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions domain/wollemi/service_symlink_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,31 @@ func (this *Service) SymlinkList(name string, broken, prune bool, exclude, inclu
return nil
}

if strings.HasPrefix(link, this.root) {
log := this.log.
WithField("link", strings.TrimPrefix(path, this.GoSrcPath()+"/")).
WithField("path", strings.TrimPrefix(link, this.root+"/"))

if broken {
_, err := this.filesystem.Stat(link)
if err == nil {
return nil
}

if !os.IsNotExist(err) {
log.WithError(err).Warn("could not stat link")
return nil
}
log := this.log.
WithField("link", strings.TrimPrefix(path, this.GoSrcPath()+"/")).
WithField("path", strings.TrimPrefix(link, this.root+"/"))

if broken {
_, err := this.filesystem.Stat(link)
if err == nil {
return nil
}

if prune {
if err := this.filesystem.Remove(path); err != nil {
log.WithError(err).Warn("could not remove link")
return nil
}
if !os.IsNotExist(err) {
log.WithError(err).Warn("could not stat link")
return nil
}
}

log.Info("symlink deleted")
} else {
log.Info("symlink")
if prune {
if err := this.filesystem.Remove(path); err != nil {
log.WithError(err).Warn("could not remove link")
return nil
}

log.Info("symlink deleted")
} else {
log.Info("symlink")
}
}

Expand Down

0 comments on commit fb9f8dd

Please sign in to comment.