@@ -13,29 +13,6 @@ import (
13
13
"golang.org/x/sync/errgroup"
14
14
)
15
15
16
- // List of forbidden paths that cannot be moved to trash
17
- var forbiddenPaths = []string {
18
- // Default trash-related paths
19
- "$HOME/.local/share/Trash" ,
20
- "$HOME/.trash" ,
21
- "$XDG_DATA_HOME/Trash" ,
22
- "/tmp/Trash" ,
23
- "/var/tmp/Trash" ,
24
-
25
- // gomi dir
26
- "$HOME/.gomi" ,
27
-
28
- // Critical system directories
29
- "/" ,
30
- "/etc" ,
31
- "/usr" ,
32
- "/var" ,
33
- "/bin" ,
34
- "/sbin" ,
35
- "/lib" ,
36
- "/lib64" ,
37
- }
38
-
39
16
// Put moves files to trash
40
17
func (c * CLI ) Put (args []string ) error {
41
18
slog .Debug ("cli.put started" )
@@ -80,7 +57,7 @@ func (c *CLI) processFile(arg string, failed *syncStringSlice) error {
80
57
}
81
58
82
59
// Check for forbidden paths
83
- if isForbiddenPath (expandedPath ) {
60
+ if c . isForbiddenPath (expandedPath ) {
84
61
failed .Append (arg )
85
62
return fmt .Errorf ("refusing to remove forbidden path: %q" , arg )
86
63
}
@@ -161,10 +138,10 @@ func expandPath(path string) (string, error) {
161
138
}
162
139
163
140
// isForbiddenPath checks if the given path is in the forbidden paths list
164
- func isForbiddenPath (path string ) bool {
141
+ func ( c * CLI ) isForbiddenPath (path string ) bool {
165
142
path = filepath .Clean (path )
166
143
167
- for _ , forbiddenPath := range forbiddenPaths {
144
+ for _ , forbiddenPath := range c . config . Core . Trash . ForbiddenPaths {
168
145
// Expand forbidden path with environment variables
169
146
expandedForbiddenPath := os .ExpandEnv (forbiddenPath )
170
147
expandedForbiddenPath = filepath .Clean (expandedForbiddenPath )
0 commit comments