play nice with other implementations that replace " " with "%20"
This commit is contained in:
parent
f9232a095b
commit
a3ff94ec8e
|
@ -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", " ")
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue