Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Xdg Trash specification to stay compatible with other file managers #4

Closed
guildem opened this issue Apr 7, 2024 · 35 comments
Closed
Labels
bug Something isn't working enhancement New feature or request

Comments

@guildem
Copy link

guildem commented Apr 7, 2024

Seems you use a trashfolder into your config folder. This is not compatible with XDG Trash specification and can lead to incompatibilities with other file managers. Also when trashing files on other disks it will make a full copy when moving the file, this can take a lot of time and will abnormally grow the config folder and home (or root) partition.

The specifications : https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html (with multi device folders)

Some trash management softwares (none in archlinux extra, only aur) : https://wiki.archlinux.org/title/Trash_management

@mhnightcat
Copy link
Owner

Thanks for the information!!

I update it! xdg/trash

Update will release in v1.0.1 886dbfb

@guildem
Copy link
Author

guildem commented Apr 7, 2024

Nice addition, works like you did, but with the correct xdg specification. However, looking xdg/trash, seems it doesn't use the $topdir/.Trash specification to trash files from another partitions without copying them to the home trash folder. This could be a feature to implement later, or an issue to fill on xdg/trash package.

@guildem
Copy link
Author

guildem commented Apr 7, 2024

Issue added to xdg/trash :-)

@mhnightcat
Copy link
Owner

Oh, thanks for checking
I didnt test it in the usb etc, i will fix it in next few day!

@mhnightcat
Copy link
Owner

image
There's definitely something wrong with this

@mhnightcat mhnightcat added the enhancement New feature or request label Apr 7, 2024
@mhnightcat
Copy link
Owner

@guildem
What do u think about just deleting files when in the another partitions

@guildem
Copy link
Author

guildem commented Apr 8, 2024

Having 2 different behaviors for one action is not what I would encourage.

Moving files from other partitions to the home trash can be time consuming and take too much space (ie. small root ssd with trash and big hdd with big files to trash), but it stays coherent. All files are trashed and can be recovered.

Having trash (and recovery) on main partition and deletion on others can lead to errors when mounting multiple partitions (I have a share folder in my $HOME mounted on a 2TB HDD to store big files).

Temporary solution : a trash action and a delete action on the home partition, and only a delete action on other partitions.

Enhancement : getting trash on other partitions functional, by waiting xdg/trash to be fixed or forking it and adding yourself the functionality + PR to upstream.

Would that be a good compromise to you ?

@mhnightcat
Copy link
Owner

so this is my final solution for now

Screencast.from.2024-04-08.19-20-58.webm

@guildem
Copy link
Author

guildem commented Apr 8, 2024

I'm not sure to understand what you've done, but maybe the better choice is to wait for the trash package to implement other trashes itself (or make a PR) ?

@mhnightcat
Copy link
Owner

The method I currently use is to delete it directly if it is no longer local, but a confirmation message will be displayed before deletion.

There is no xdg in macos, so macos currently deletes it directly.

And btw i dont have any Mac so i cant test it........

@guildem
Copy link
Author

guildem commented Apr 8, 2024

For macos you should have this (untested) : https://github.com/Bios-Marcel/wastebasket or this https://apple.stackexchange.com/a/310084 (no lib)

Globally I stay on the position that one action giving 2 different behaviors (even with a popup) isn't great, and 2 actions could be better, one for trash, one for delete (like ranger with DD to delete and DT to trash). And if you can't trash because unimplemented for other partitions/OSes, a popup explaining why you can't

@mhnightcat
Copy link
Owner

mhnightcat commented Apr 9, 2024

OK i will try this

But the biggest problem with macos is that I don’t have a machine to test :(
haha

@mhnightcat mhnightcat added bug Something isn't working todo labels Apr 9, 2024
@mhnightcat
Copy link
Owner

@AnshumanNeon Sorry to tag you :(
Can you help me test whether the new version will throw files into the trash can on MacOs?

@AnshumanNeon
Copy link
Contributor

yeah sure

@AnshumanNeon
Copy link
Contributor

Screenshot 2024-04-16 at 9 22 54 PM
at function.go 826 you access the element of an array at index 0. but the array is empty. That means it isn't initalized. It should have at least a null value before accessing it.

@mhnightcat
Copy link
Owner

mhnightcat commented Apr 16, 2024

Oh I know why.
You can try to regenerate hotkeys.toml
I added some hotkeys and I think that's why it's causing this error

@AnshumanNeon
Copy link
Contributor

I rebuilt the whole config folder. but it is showing error on deleting. and the file isn't deleted
Screenshot 2024-04-16 at 9 34 29 PM

@mhnightcat
Copy link
Owner

mhnightcat commented Apr 16, 2024

Ok thanks for your testing!
Can you send it back to me to see the contents of superfile.log?
Should be in ~/.cache/superfile

@AnshumanNeon
Copy link
Contributor

2024/04/14 14:43:41 err when open file with xdg-open:
2024/04/14 14:43:41 exec: "xdg-open": executable file not found in $PATH
2024/04/16 21:33:57 Delete single item function move file to trash can error
2024/04/16 21:33:57 exit status 1
2024/04/16 21:34:21 Delete single item function move file to trash can error
2024/04/16 21:34:21 exit status 1
2024/04/16 21:38:39 Delete single item function move file to trash can error
2024/04/16 21:38:39 exit status 1

superfile.log logs. so you are trying to call "xdg-open" which is a program that needs to be installed?

@mhnightcat
Copy link
Owner

mhnightcat commented Apr 16, 2024

// ...
	} else if len(panel.element) > 0 && !panel.element[panel.cursor].directory {
		cmd := exec.Command("xdg-open", panel.element[panel.cursor].location)
		_, err := cmd.Output()
		if err != nil {
			outPutLog("err when open file with xdg-open:", err)
		}
	}
// ...
}
2024/04/14 14:43:41 err when open file with xdg-open:
2024/04/14 14:43:41 exec: "xdg-open": executable file not found in $PATH

I think this is another error.

@AnshumanNeon
Copy link
Contributor

https://superuser.com/a/913226
as mentioned in this answer, you should probably use "open" command for darwin

@AnshumanNeon
Copy link
Contributor

2024/04/16 21:52:09 Delete single item function move file to trash can error
2024/04/16 21:52:09 exit status 1

this is the error when trying again after installing xdg-utils

@mhnightcat
Copy link
Owner

mhnightcat commented Apr 16, 2024

Ok i got it.
I'll fix it in 7d03edf

And about the Macos trash can, I think I'll fix it tomorrow :(

@AnshumanNeon
Copy link
Contributor

no problem

@AnshumanNeon
Copy link
Contributor

@mhnightcat i found a really easy solution. It is in this thread https://apple.stackexchange.com/a/310084 mentioned by @guildem
I am talking about this specific solution: https://apple.stackexchange.com/a/335164
it is easy and cheap and it works on my mac.

@mhnightcat
Copy link
Owner

bb55ece
Thanks for responding, I already updated it!

@AnshumanNeon
Copy link
Contributor

but this is what is already there. That osascript isn't working.

@mhnightcat
Copy link
Owner

Oh~ ok got it i will update again!

@mhnightcat
Copy link
Owner

mhnightcat commented Apr 17, 2024

@AnshumanNeon I update it in 5dfbcb9

@mhnightcat
Copy link
Owner

mhnightcat commented Apr 18, 2024

Does this work?
I think after this fix this issue i will release v1.1.0

@AnshumanNeon
Copy link
Contributor

no it doesn't. Here is the log:

2024/04/19 17:14:01 Delete single item function move file to trash can error
2024/04/19 17:14:01 exit status 1

@AnshumanNeon
Copy link
Contributor

sorry for being late

@mhnightcat
Copy link
Owner

It's fine!
I update it again in d34ee13
Could you please give it a try?

@AnshumanNeon
Copy link
Contributor

AnshumanNeon commented Apr 20, 2024

yes it works now! it moves it to trash dir without errors. Congrats
nice work

@mhnightcat
Copy link
Owner

mhnightcat commented Apr 20, 2024

OK, thanks for testing!

I close this issue for now.
But if you have any better ideas about this, feel free to reopen

still can’t put the files on the external hard drive into the trash btw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants