Skip to content

Commit fca6112

Browse files
committed
fix: Fix rabbit comments
1 parent 3a9007c commit fca6112

File tree

8 files changed

+19
-10
lines changed

8 files changed

+19
-10
lines changed

src/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func spfAppAction(_ context.Context, c *cli.Command) error {
130130

131131
firstUse := checkFirstUse()
132132

133-
p := tea.NewProgram(internal.InitialModel(firstFilePanelDirs, firstUse, common.InitTrash()),
133+
p := tea.NewProgram(internal.InitialModel(firstFilePanelDirs, firstUse),
134134
tea.WithAltScreen(), tea.WithMouseCellMotion())
135135
if _, err := p.Run(); err != nil {
136136
utils.PrintfAndExit("Alas, there's been an error: %v", err)

src/config/fixed_variable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var (
4949
DarwinTrashDirectory = filepath.Join(HomeDir, ".Trash")
5050

5151
// These are used by github.com/rkoesters/xdg/trash package
52-
// We need to make sure that these directories exists
52+
// We need to make sure that these directories exist
5353
LinuxTrashDirectory = filepath.Join(xdg.DataHome, "Trash")
5454
LinuxTrashDirectoryFiles = filepath.Join(xdg.DataHome, "Trash", "files")
5555
LinuxTrashDirectoryInfo = filepath.Join(xdg.DataHome, "Trash", "info")

src/internal/common/load_config.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,15 @@ func InitTrash() bool {
334334
if runtime.GOOS != utils.OsLinux {
335335
return true
336336
}
337-
return utils.CreateDirectories(
337+
err := utils.CreateDirectories(
338338
variable.LinuxTrashDirectory,
339339
variable.LinuxTrashDirectoryFiles,
340340
variable.LinuxTrashDirectoryInfo,
341-
) == nil
341+
)
342+
if err != nil {
343+
slog.Warn("Failed to initialize XDG trash; falling back to permanent delete",
344+
"error", err, "trashDir", variable.LinuxTrashDirectory)
345+
return false
346+
}
347+
return true
342348
}

src/internal/default_config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
// Maybe we can replace slice of strings with var args - Should we ?
1717
// TODO: Move the configuration parameters to a ModelConfig struct.
1818
// Something like `RendererConfig` struct for `Renderer` struct in ui/renderer package
19-
func defaultModelConfig(toggleDotFile, toggleFooter, firstUse, hasTrash bool, firstFilePanelDirs []string) *model {
19+
func defaultModelConfig(toggleDotFile, toggleFooter, firstUse bool, firstFilePanelDirs []string) *model {
2020
return &model{
2121
filePanelFocusIndex: 0,
2222
focusPanel: nonePanelFocus,
@@ -42,7 +42,7 @@ func defaultModelConfig(toggleDotFile, toggleFooter, firstUse, hasTrash bool, fi
4242
toggleDotFile: toggleDotFile,
4343
toggleFooter: toggleFooter,
4444
firstUse: firstUse,
45-
hasTrash: hasTrash,
45+
hasTrash: common.InitTrash(),
4646
}
4747
}
4848

src/internal/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ var et *exiftool.Exiftool //nolint: gochec
3636
// is passed to tea.NewProgram() which accepts tea.Model
3737
// Either way type 'model' is not exported, so there is not way main package can
3838
// be aware of it, and use it directly
39-
func InitialModel(firstFilePanelDirs []string, firstUseCheck, hasTrash bool) tea.Model {
39+
func InitialModel(firstFilePanelDirs []string, firstUseCheck bool) tea.Model {
4040
toggleDotFile, toggleFooter := initialConfig(firstFilePanelDirs)
4141
batCmd = checkBatCmd()
42-
return defaultModelConfig(toggleDotFile, toggleFooter, firstUseCheck, hasTrash, firstFilePanelDirs)
42+
return defaultModelConfig(toggleDotFile, toggleFooter, firstUseCheck, firstFilePanelDirs)
4343
}
4444

4545
// Init function to be called by Bubble tea framework, sets windows title,

src/internal/model_file_operations_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func TestFileRename(t *testing.T) {
141141
actualTest := func(doRename bool) {
142142
m := defaultTestModel(curTestDir)
143143
p := NewTestTeaProgWithEventLoop(t, m)
144-
setFilePanelSelectedItemByLocation(t, m.getFocusedFilePanel(), file2)
144+
setFilePanelSelectedItemByLocation(t, m.getFocusedFilePanel(), file3)
145145

146146
p.SendKeyDirectly(common.Hotkeys.FilePanelItemRename[0])
147147
m.getFocusedFilePanel().rename.SetValue("file2.txt")

src/internal/test_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func setupFiles(t *testing.T, files ...string) {
4444
// -------------------- Model setup utils
4545

4646
func defaultTestModel(dirs ...string) *model {
47-
m := defaultModelConfig(false, false, false, false, dirs)
47+
m := defaultModelConfig(false, false, false, dirs)
4848
m.disableMetatdata = true
4949
_, _ = TeaUpdate(m, tea.WindowSizeMsg{Width: 2 * common.MinimumWidth, Height: 2 * common.MinimumHeight})
5050
return m

src/internal/utils/file_utils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ func DirSize(path string) int64 {
221221
// Create all dirs that does not already exists
222222
func CreateDirectories(dirs ...string) error {
223223
for _, dir := range dirs {
224+
if dir == "" {
225+
continue
226+
}
224227
if err := os.MkdirAll(dir, 0755); err != nil {
225228
return fmt.Errorf("failed to create directory %s: %w", dir, err)
226229
}

0 commit comments

Comments
 (0)