Skip to content

Commit

Permalink
update $HOME/.superfile to $HOME/.config/superfile and update trash c…
Browse files Browse the repository at this point in the history
…an path to match The FreeDesktop.org Trash specification
  • Loading branch information
yorukot committed Apr 7, 2024
1 parent 41ed813 commit 886dbfb
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 41 deletions.
23 changes: 0 additions & 23 deletions .goreleaser.yaml

This file was deleted.

12 changes: 10 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,31 @@ 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)

# [**Beta 0.1.0**](https://github.com/MHNightCat/superfile/releases/tag/v0.1.0-beta)

> 2024/04/06
- FIRST RELEASE COME UP! NO ANY CHANGE
- FIRST RELEASE COME UP! NO ANY CHANGE
40 changes: 40 additions & 0 deletions src/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -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 <nightcat.dev@proton.me>
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 }}
4 changes: 2 additions & 2 deletions src/components/globalController.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

This comment has been minimized.

Copy link
@guildem

guildem Apr 7, 2024

This should be a backup folder only if $XDG_CONFIG_HOME doesn't exists.

To not access the env var directly you can use https://pkg.go.dev/github.com/rkoesters/xdg/basedir.

Don't forget to change the dataFolder to $XDG_DATA_HOME or the rkoesters/xdg/basedirequivalent.


var theme ThemeType
var Config ConfigType
Expand Down
7 changes: 6 additions & 1 deletion src/components/normalModeController.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/components/selectModeController.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
7 changes: 1 addition & 6 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

var HomeDir = getHomeDir()
var SuperFileMainDir = HomeDir + "/.superfile"
var SuperFileMainDir = HomeDir + "/.config/superfile"

const (
currentVersion string = "v1.0.1"
Expand Down Expand Up @@ -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 {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 886dbfb

Please sign in to comment.