Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
handle broken links with 'select' command
Browse files Browse the repository at this point in the history
Related gokcehan#201
  • Loading branch information
gokcehan committed Jul 19, 2020
1 parent 6d1a840 commit 7174b7e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ func (app *app) loop() {

if gSelect != "" {
go func() {
stat, err := os.Stat(gSelect)
lstat, err := os.Lstat(gSelect)
if err != nil {
app.ui.exprChan <- &callExpr{"echoerr", []string{err.Error()}, 1}
} else if stat.IsDir() {
} else if lstat.IsDir() {
app.ui.exprChan <- &callExpr{"cd", []string{gSelect}, 1}
} else {
app.ui.exprChan <- &callExpr{"select", []string{gSelect}, 1}
Expand Down
4 changes: 2 additions & 2 deletions copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ func copyAll(srcs []string, dstDir string) (nums chan int64, errs chan error) {
for _, src := range srcs {
dst := filepath.Join(dstDir, filepath.Base(src))

_, err := os.Stat(dst)
_, err := os.Lstat(dst)
if !os.IsNotExist(err) {
var newPath string
for i := 1; !os.IsNotExist(err); i++ {
newPath = fmt.Sprintf("%s.~%d~", dst, i)
_, err = os.Stat(newPath)
_, err = os.Lstat(newPath)
}
dst = newPath
}
Expand Down
2 changes: 1 addition & 1 deletion eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.toggle()
} else {
for _, path := range e.args {
if _, err := os.Stat(path); err == nil {
if _, err := os.Lstat(path); err == nil {
app.nav.toggleSelection(path)
} else {
log.Printf("toggle: %s", err)
Expand Down
6 changes: 3 additions & 3 deletions nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (nav *nav) renew() {
}

for m := range nav.selections {
if _, err := os.Stat(m); os.IsNotExist(err) {
if _, err := os.Lstat(m); os.IsNotExist(err) {
delete(nav.selections, m)
}
}
Expand Down Expand Up @@ -732,7 +732,7 @@ func (nav *nav) moveAsync(ui *ui, srcs []string, dstDir string) {
var newPath string
for i := 1; !os.IsNotExist(err); i++ {
newPath = fmt.Sprintf("%s.~%d~", dst, i)
_, err = os.Stat(newPath)
_, err = os.Lstat(newPath)
}
dst = newPath
}
Expand Down Expand Up @@ -914,7 +914,7 @@ func (nav *nav) sel(path string) error {
path = replaceTilde(path)
path = filepath.Clean(path)

lstat, err := os.Stat(path)
lstat, err := os.Lstat(path)
if err != nil {
return fmt.Errorf("select: %s", err)
}
Expand Down

0 comments on commit 7174b7e

Please sign in to comment.