From 886dbfb276407db36e9fb7369ec31053e7aabcf4 Mon Sep 17 00:00:00 2001 From: Night Cat <107802416+MHNightCat@users.noreply.github.com> Date: Sun, 7 Apr 2024 19:18:57 +0800 Subject: [PATCH] update $HOME/.superfile to $HOME/.config/superfile and update trash can path to match The FreeDesktop.org Trash specification --- .goreleaser.yaml | 23 ----------- changelog.md | 12 +++++- src/.goreleaser.yaml | 40 +++++++++++++++++++ src/components/globalController.go | 4 +- src/components/model.go | 5 +-- src/components/normalModeController.go | 7 +++- src/components/selectModeController.go | 9 +++-- src/go.mod | 1 + src/go.sum | 2 + src/main.go | 7 +--- .../config/config.json | 0 .../data/lastCheckVersion | 0 .../data/pinned.json | 0 .../theme/gruvbox.json | 0 src/{.superfile => superfile}/theme/nord.json | 0 15 files changed, 69 insertions(+), 41 deletions(-) delete mode 100644 .goreleaser.yaml create mode 100644 src/.goreleaser.yaml rename src/{.superfile => superfile}/config/config.json (100%) rename src/{.superfile => superfile}/data/lastCheckVersion (100%) rename src/{.superfile => superfile}/data/pinned.json (100%) rename src/{.superfile => superfile}/theme/gruvbox.json (100%) rename src/{.superfile => superfile}/theme/nord.json (100%) diff --git a/.goreleaser.yaml b/.goreleaser.yaml deleted file mode 100644 index 172b8d48..00000000 --- a/.goreleaser.yaml +++ /dev/null @@ -1,23 +0,0 @@ -version: 1 - -before: - hooks: - - cd ./src && go mod tidy - -builds: - - main: ./src/main.go - id: "superfile" - binary: spf - goos: - - linux - - darwin - -archives: - - format: tar.gz - name_template: >- - ./{{ .ProjectName }}_ - ./{{- title .Os }}_ - ./{{- if eq .Arch "amd64" }}x86_64 - ./{{- else if eq .Arch "386" }}i386 - ./{{- else }}{{ .Arch }}{{ end }} - ./{{- if .Arm }}v{{ .Arm }}{{ end }} \ No newline at end of file diff --git a/changelog.md b/changelog.md index 16f11d1f..133cc3ff 100644 --- a/changelog.md +++ b/changelog.md @@ -7,18 +7,26 @@ All notable changes to this project will be documented in this file. Dates are d > 2024/04/xx #### Update + +- Update $HOME/.superfile to $HOME/.config/superfile [`f6eb9d8`](https://github.com/MHNightCat/superfile/commit/f6eb9d879f9f7ef31859e3f84c8792e2f0fc543a) +- Follow [The FreeDesktop.org Trash specification](https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html) [`f6eb9d8`] to update the trash bin path (https://github.com/MHNightCat/superfile/commit/f6eb9d879f9f7ef31859e3f84c8792e2f0fc543a) + #### Bug fix -- Fix processes bar cursor index display error[`f6eb9d8`](https://github.com/MHNightCat/superfile/commit/f6eb9d879f9f7ef31859e3f84c8792e2f0fc543a) + +- Fix processes bar cursor index display error [`f6eb9d8`](https://github.com/MHNightCat/superfile/commit/f6eb9d879f9f7ef31859e3f84c8792e2f0fc543a) # [**v1.0.0**](https://github.com/MHNightCat/superfile/releases/tag/v1.0.0) > 2024/04/06 ##### Update + - Auto download folder [`96a3a71`](https://github.com/MHNightCat/superfile/commit/96a3a7108eb7c4327bad3424ed55e472ec78049f) - Auto initialize configuration [`96a3a71`](https://github.com/MHNightCat/superfile/commit/96a3a7108eb7c4327bad3424ed55e472ec78049f) - Add version subcommand [`ee22df3`](https://github.com/MHNightCat/superfile/commit/ee22df3c7700adddb859ada8623f6c8b038e8087) + ##### Bug fix + - Fix creating an Item when the file panel has no Item will cause an error [`9ee1d86`](https://github.com/MHNightCat/superfile/commit/9ee1d860192182803d408c5046ca9f5255121698) - Fix delete mupulate Item will cause cursor error [`ee22df3`](https://github.com/MHNightCat/superfile/commit/ee22df3c7700adddb859ada8623f6c8b038e8087) @@ -26,4 +34,4 @@ All notable changes to this project will be documented in this file. Dates are d > 2024/04/06 -- FIRST RELEASE COME UP! NO ANY CHANGE \ No newline at end of file +- FIRST RELEASE COME UP! NO ANY CHANGE diff --git a/src/.goreleaser.yaml b/src/.goreleaser.yaml new file mode 100644 index 00000000..c0a361c2 --- /dev/null +++ b/src/.goreleaser.yaml @@ -0,0 +1,40 @@ +version: 1 + +before: + hooks: + - go mod tidy + +builds: + - main: ./main.go + id: "superfile" + binary: spf + goos: + - linux + - darwin + goarch: + - amd64 + - arm + - arm64 + +nfpms: + - maintainer: NightCat + file_name_template: >- + {{ .PackageName }}-{{ .Version }}-{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}-{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }} + description: Pretty fancy and modern file manager in terminal . + homepage: https://github.com/MHNightCat/superfile + bindir: /usr/bin + license: MIT + formats: + - deb + - rpm + - archlinux + +archives: + - format: tar.gz + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} \ No newline at end of file diff --git a/src/components/globalController.go b/src/components/globalController.go index 74d711ed..3d2b0136 100644 --- a/src/components/globalController.go +++ b/src/components/globalController.go @@ -10,6 +10,7 @@ import ( "github.com/charmbracelet/bubbles/progress" "github.com/charmbracelet/bubbles/textinput" "github.com/lithammer/shortuuid" + "github.com/rkoesters/xdg/trash" ) /* CURSOR CONTROLLER START */ @@ -334,8 +335,7 @@ func PasteItem(m model) model { } if m.copyItems.cut { for _, item := range m.copyItems.items { - filePath := item - err := MoveFile(item, SuperFileMainDir+trashFolder+"/"+path.Base(filePath)) + err := trash.Trash(item) if err != nil { OutPutLog("Paste item function move file to trash can error", err) } diff --git a/src/components/model.go b/src/components/model.go index 093d3712..c46af86d 100644 --- a/src/components/model.go +++ b/src/components/model.go @@ -13,17 +13,16 @@ import ( const ( configFolder string = "/config" themeFolder string = "/theme" - trashFolder string = "/trash" dataFolder string = "/data" lastCheckVersion string = "/data/lastCheckVersion" pinnedFile string = "/data/pinned.json" + logFile string = "/data/superfile.log" configFile string = "/config/config.json" themeZipName string = "/theme.zip" - logFile string = "/superfile.log" ) var HomeDir = getHomeDir() -var SuperFileMainDir = HomeDir + "/.superfile" +var SuperFileMainDir = HomeDir + "/.config/superfile" var theme ThemeType var Config ConfigType diff --git a/src/components/normalModeController.go b/src/components/normalModeController.go index f86910c9..4ba2a807 100644 --- a/src/components/normalModeController.go +++ b/src/components/normalModeController.go @@ -9,6 +9,7 @@ import ( "github.com/charmbracelet/bubbles/progress" "github.com/charmbracelet/bubbles/textinput" "github.com/lithammer/shortuuid" + "github.com/rkoesters/xdg/trash" ) func EnterPanel(m model) model { @@ -76,7 +77,11 @@ func DeleteSingleItem(m model) model { processNewState: newProcess, } - err := MoveFile(panel.element[panel.cursor].location, SuperFileMainDir+trashFolder+"/"+panel.element[panel.cursor].name) + err := trash.Trash(panel.element[panel.cursor].location) + if err != nil { + OutPutLog("Delete single item function move file to trash can error", err) + } + if err != nil { p := m.processBarModel.process[id] p.state = failure diff --git a/src/components/selectModeController.go b/src/components/selectModeController.go index dd6a795b..12a4b1ab 100644 --- a/src/components/selectModeController.go +++ b/src/components/selectModeController.go @@ -2,12 +2,11 @@ package components import ( "os" - "path" "path/filepath" - "github.com/atotto/clipboard" "github.com/charmbracelet/bubbles/progress" "github.com/lithammer/shortuuid" + "github.com/rkoesters/xdg/trash" ) func SingleItemSelect(m model) model { @@ -100,8 +99,10 @@ func DeleteMultipleItem(m model) model { processNewState: p, } } - - err := MoveFile(filePath, SuperFileMainDir+trashFolder+"/"+path.Base(filePath)) + err := trash.Trash(filePath) + if err != nil { + OutPutLog("Delete single item function move file to trash can error", err) + } if err != nil { p.state = failure diff --git a/src/go.mod b/src/go.mod index 8948900e..79d0efd8 100644 --- a/src/go.mod +++ b/src/go.mod @@ -29,6 +29,7 @@ require ( github.com/muesli/termenv v0.15.2 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/rivo/uniseg v0.4.6 // indirect + github.com/rkoesters/xdg v0.0.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/satori/go.uuid v1.2.0 // indirect github.com/stretchr/testify v1.8.4 // indirect diff --git a/src/go.sum b/src/go.sum index 4c83185a..db9c16a6 100644 --- a/src/go.sum +++ b/src/go.sum @@ -54,6 +54,8 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.6 h1:Sovz9sDSwbOz9tgUy8JpT+KgCkPYJEN/oYzlJiYTNLg= github.com/rivo/uniseg v0.4.6/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rkoesters/xdg v0.0.1 h1:RmfYxghVvIsb4d51u5LtNOcwqY5r3P44u6o86qqvBMA= +github.com/rkoesters/xdg v0.0.1/go.mod h1:5DcbjvJkY00fIOKkaBnylbC/rmc1NNJP5dmUcnlcm7U= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= diff --git a/src/main.go b/src/main.go index e404d897..9e6703c5 100644 --- a/src/main.go +++ b/src/main.go @@ -18,7 +18,7 @@ import ( ) var HomeDir = getHomeDir() -var SuperFileMainDir = HomeDir + "/.superfile" +var SuperFileMainDir = HomeDir + "/.config/superfile" const ( currentVersion string = "v1.0.1" @@ -85,11 +85,6 @@ func InitConfigFile() { if err != nil { log.Fatalln("Can't Create Superfile main config folder:", SuperFileMainDir, err) } - // create trash can folder - err = CreateFolderIfNotExist(SuperFileMainDir + trashFolder) - if err != nil { - log.Fatalln("Can't Create Superfile trash folder:", SuperFileMainDir+trashFolder, err) - } // create data folder err = CreateFolderIfNotExist(SuperFileMainDir + dataFolder) if err != nil { diff --git a/src/.superfile/config/config.json b/src/superfile/config/config.json similarity index 100% rename from src/.superfile/config/config.json rename to src/superfile/config/config.json diff --git a/src/.superfile/data/lastCheckVersion b/src/superfile/data/lastCheckVersion similarity index 100% rename from src/.superfile/data/lastCheckVersion rename to src/superfile/data/lastCheckVersion diff --git a/src/.superfile/data/pinned.json b/src/superfile/data/pinned.json similarity index 100% rename from src/.superfile/data/pinned.json rename to src/superfile/data/pinned.json diff --git a/src/.superfile/theme/gruvbox.json b/src/superfile/theme/gruvbox.json similarity index 100% rename from src/.superfile/theme/gruvbox.json rename to src/superfile/theme/gruvbox.json diff --git a/src/.superfile/theme/nord.json b/src/superfile/theme/nord.json similarity index 100% rename from src/.superfile/theme/nord.json rename to src/superfile/theme/nord.json