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

OS.move_to_trash() gives wrong error message for non-existent file. #67157

Closed
amoriqbal opened this issue Oct 9, 2022 · 5 comments · Fixed by #67158 or #79284
Closed

OS.move_to_trash() gives wrong error message for non-existent file. #67157

amoriqbal opened this issue Oct 9, 2022 · 5 comments · Fixed by #67158 or #79284

Comments

@amoriqbal
Copy link
Contributor

amoriqbal commented Oct 9, 2022

Godot version

4.0 beta 2

System information

Linux Mint 20.3, i7 9th Gen, NVIDIA GeForce GTX 1650, Vulkan

Issue description

I am using OS.move_to_trash("abcd.txt") in a script. The file abcd.txt does not exist. We expect an error like "File not found" or "File does not exist". Instead the error message displayed is _ready: Can't rename file "abcd.txt" to "/abcd.txt".

Steps to reproduce

Use the following _ready function in a GDScript file and let it run.

func _ready():
	OS.move_to_trash("abcd.txt") 

If the file abcd.txt exists, then the code will work as expected.
If the file abcd.txt does not exist, then this error will appear _ready: Can't rename file "abcd.txt" to "/abcd.txt".

Minimal reproduction project

WrongErrorMsg.zip

Bugsquad edit (keywords for easier searching): move_to_trash

@Calinou
Copy link
Member

Calinou commented Oct 9, 2022

Related to #67137.

@amoriqbal
Copy link
Contributor Author

The problem seems to originate in the file os_linuxbsd.cpp, in the function OS_LinuxBSD::move_to_trash.
In line no 624,
execute("gio", args, nullptr, &err_code); returns with err_code value 1 if the file to be deleted does not exist.
But the existing code checks for err_code == 2 to determine if the file to be deleted does not exist. (line no 625)

The same is repeated for execute("kioclient5", args, nullptr, &err_code); and execute("gvfs-trash", args, nullptr, &err_code);

@amoriqbal
Copy link
Contributor Author

It would be nice if someone with a KDE system could test the bug.
(I mean test it on one of the following OS's : lUbubtu, MXLinux, KDE Linux, etc)
Thanks.

@amoriqbal
Copy link
Contributor Author

This issue is present in 3.x branch too.

@amoriqbal
Copy link
Contributor Author

reproduced on KDE Neon OS too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment