diff --git a/internal/dirs/dirs.go b/internal/dirs/dirs.go index 64e1854..b1a08c7 100644 --- a/internal/dirs/dirs.go +++ b/internal/dirs/dirs.go @@ -31,5 +31,11 @@ func UnExpand(dir, workdir string) (outdir string) { outdir = strings.Replace(outdir, home, "~", 1) + outdir = UnEscape(outdir) + return } + +func UnEscape(input string) string { + return strings.ReplaceAll(input, "%20", " ") +} diff --git a/internal/tables/tables.go b/internal/tables/tables.go index 887b632..cca0e0f 100644 --- a/internal/tables/tables.go +++ b/internal/tables/tables.go @@ -88,7 +88,7 @@ func newInfosModel(is trash.Infos, width, height int, readonly, preselected bool b = humanize.Bytes(uint64(i.Filesize())) } r := table.Row{ - i.Name(), + dirs.UnEscape(i.Name()), dirs.UnExpand(filepath.Dir(i.OGPath()), ""), t, b, @@ -149,7 +149,7 @@ func newFilesModel(fs files.Files, width, height int, readonly, preselected bool b = humanize.Bytes(uint64(f.Filesize())) } r := table.Row{ - f.Name(), + dirs.UnEscape(f.Name()), dirs.UnExpand(f.Path(), workdir), t, b, diff --git a/internal/trash/trash.go b/internal/trash/trash.go index d622cbc..d81f86c 100644 --- a/internal/trash/trash.go +++ b/internal/trash/trash.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "git.burning.moe/celediel/gt/internal/dirs" "git.burning.moe/celediel/gt/internal/filter" "github.com/charmbracelet/log" "github.com/dustin/go-humanize" @@ -111,8 +112,9 @@ func FindFiles(trashdir, ogdir string, f *filter.Filter) (files Infos, outerr er func Restore(files []Info) (restored int, err error) { for _, file := range files { - log.Infof("restoring %s back to %s\n", file.name, file.ogpath) - if err = os.Rename(file.path, file.ogpath); err != nil { + var outpath string = dirs.UnEscape(file.ogpath) + log.Infof("restoring %s back to %s\n", file.name, outpath) + if err = os.Rename(file.path, outpath); err != nil { return restored, err } if err = os.Remove(file.trashinfo); err != nil {