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

Delete from filesystem does not work: Win10 64bit VLC 3.0.18 Vetinari #15

Closed
fun29 opened this issue Jun 15, 2023 · 15 comments
Closed

Delete from filesystem does not work: Win10 64bit VLC 3.0.18 Vetinari #15

fun29 opened this issue Jun 15, 2023 · 15 comments
Assignees
Labels
Milestone

Comments

@fun29
Copy link

fun29 commented Jun 15, 2023

See debug output attached, the file still exists after using the "Remove current file" menu-item.

Error in the debug log:
lua info: [vlc-delete] error: File does not exist

vlc.debug.txt

@surrim
Copy link
Owner

surrim commented Jun 15, 2023

Thanks for your report. Was there anything special with the filename? Unicode letters, network drive, etc?

@fun29
Copy link
Author

fun29 commented Jun 16, 2023

Initially yes. Then I renamed it to something like "abc.mp4" on a normal drive (no UNC etc..) and it still failed.
Even when running it as administrator.
So that's when I decided to report it with the full vlc debug log.
You can see the filename there also.

@surrim
Copy link
Owner

surrim commented Jun 16, 2023

lua info: [vlc-delete] removing: G:/file.mp4

Can you try to get some more information/debug the script please? Maybe my windows detection is not working for Win10.
I'm using Linux since 2004, and I never had something newer than Win 7 to test.

@fun29
Copy link
Author

fun29 commented Jun 17, 2023

The output message "File does not exist" only exists in function windowsDelete so it seems to detect windows.

Perhaps the gsub, translating / into \ does not work?

lua info: [vlc-delete] removing: G:/file.mp4
main info: playlist is empty
lua info: [vlc-delete] error: File does not exist

@fun29
Copy link
Author

fun29 commented Jun 17, 2023

I've tried hardcoding the filename:

function windowsDelete()
vlc.msg.info("[vlc-delete] before")
local file = "G:\file.mp4"
os.remove(file)
vlc.msg.info("[vlc-delete] after")
end

That results in:

qt debug: activating or triggering extension 'VLC Delete'
lua debug: Activating extension 'VLC Delete'
lua info: [vlc-delete] removing: G:/file.mp4
main debug: deleting item `file.mp4'
lua info: [vlc-delete] before
main debug: incoming request - stopping current input
lua info: [vlc-delete] after
lua warning: Error while running script C:\Apps\vlc-3.0.18\lua\extensions\vlc-delete.lua, function activate(): C:\Apps\vlc-3.0.18\lua\extensions\vlc-delete.lua:106: attempt to concatenate global 'err' (a nil value)
lua error: Could not activate extension!
lua debug: Deactivating 'VLC Delete'
lua debug: Deactivating 'VLC Delete'

@fun29
Copy link
Author

fun29 commented Jun 17, 2023

Also tried this:

function windowsDelete()
vlc.msg.info("[vlc-delete] before")
local file = "G:\\file.mp4"
os.remove(file)
vlc.msg.info("[vlc-delete] after")
end

That results in:

qt debug: activating or triggering extension 'VLC Delete'
lua debug: Activating extension 'VLC Delete'
lua info: [vlc-delete] removing: G:/file.mp4
main debug: deleting item `file.mp4'
lua info: [vlc-delete] before
main debug: incoming request - stopping current input
lua info: [vlc-delete] after
lua warning: Error while running script C:\Apps\vlc-3.0.18\lua\extensions\vlc-delete.lua, function activate(): C:\Apps\vlc-3.0.18\lua\extensions\vlc-delete.lua:106: attempt to concatenate global 'err' (a nil value)
lua error: Could not activate extension!
lua debug: Deactivating 'VLC Delete'
lua debug: Deactivating 'VLC Delete'

@fun29
Copy link
Author

fun29 commented Jun 17, 2023

Also tried this:

function windowsDelete()
vlc.msg.info("[vlc-delete] before")
local file = "G:/file.mp4"
os.remove("G:/file.mp4")
vlc.msg.info("[vlc-delete] after")
end

That results in:

lua debug: Activating extension 'VLC Delete'
lua info: [vlc-delete] removing: G:/file.mp4
main debug: deleting item `file.mp4'
lua info: [vlc-delete] before
main debug: incoming request - stopping current input
main debug: incoming request - stopping current input
lua info: [vlc-delete] after
lua warning: Error while running script C:\Apps\vlc-3.0.18\lua\extensions\vlc-delete.lua, function activate(): C:\Apps\vlc-3.0.18\lua\extensions\vlc-delete.lua:106: attempt to concatenate global 'err' (a nil value)
lua error: Could not activate extension!
lua debug: Deactivating 'VLC Delete'
lua debug: Deactivating 'VLC Delete'

@fun29
Copy link
Author

fun29 commented Jun 17, 2023

Alsot tried this:

function windowsDelete()
local file = "G:/file.mp4"
f = io.open(file, "r")
vlc.msg.info("[vlc-delete] before")
f:close()
vlc.msg.info("[vlc-delete] after io.close")
os.remove(file)
vlc.msg.info("[vlc-delete] after os.remove")
end

That results in:

lua debug: Activating extension 'VLC Delete'
lua info: [vlc-delete] removing: G:/file.mp4
main debug: deleting item `file.mp4'
main debug: incoming request - stopping current input
lua info: [vlc-delete] before
lua info: [vlc-delete] after io.close
lua info: [vlc-delete] after os.remove
lua warning: Error while running script C:\Apps\vlc-3.0.18\lua\extensions\vlc-delete.lua, function activate(): C:\Apps\vlc-3.0.18\lua\extensions\vlc-delete.lua:108: attempt to concatenate global 'err' (a nil value)
lua error: Could not activate extension!
lua debug: Deactivating 'VLC Delete'
lua debug: Deactivating 'VLC Delete'

Which indicates that something is (also) wrong in:

	if (retval == nil) then
		vlc.msg.info("[vlc-delete] error: " .. err)

@fun29
Copy link
Author

fun29 commented Jun 17, 2023

I've put this complete code in a lua file: #11 (comment)

But because I don't like /f and /a I replaced:

os.execute("del /f /a /q ".."\""..path.."\"")

with:

os.execute("del /q ".."\""..path.."\"")

And then tested it.

Then the file is deleted. (and always shows two "dos box" popups for a single delete action)

So please "just" "merge" that with your main version 🙏

@surrim
Copy link
Owner

surrim commented Jun 17, 2023

Thanks a lot for your work @fun29, merged with 539dc60. Please check if it's working and don't hesitate to write feedback.

I will make a few more minor changes, not related to this issue.

@surrim surrim added this to the v0.2 milestone Jun 17, 2023
@surrim surrim added the bug label Jun 17, 2023
@fun29
Copy link
Author

fun29 commented Jun 17, 2023

I've tried your new version from main branch.

Output:

cannotdelete

lua debug: Activating extension 'VLC Delete'
lua info: [vlc-delete] removing: G:\file.mp4
lua info: [vlc-delete] error: File does not exist
lua debug: Creating dialog 'VLC Delete'
qt debug: Creating a new dialog: 'VLC Delete'
lua debug: Clicking 'C:\Apps\vlc-3.0.18\lua\extensions\vlc-delete-prerelease.lua': 'OK'
lua debug: Deleting dialog 'VLC Delete'
lua debug: Waiting for the dialog to be deleted...
qt debug: Deleting extension dialog 'VLC Delete'
lua debug: Deactivating 'VLC Delete'
lua debug: Deactivating 'VLC Delete'

@surrim
Copy link
Owner

surrim commented Jun 17, 2023

Could you check the result of if exists here?
I included this function to test the result of the del command. del always returns 0 / no error.

@surrim
Copy link
Owner

surrim commented Jun 17, 2023

Maybe

function file_exists(file)
	retval, err = os.execute("if exist \"" .. file .. "\" (exit 0) else (exit 1)")
	return type(retval) == "number" and retval == 0
end

works. At least my wine test gets the right exitcode.

@fun29
Copy link
Author

fun29 commented Jun 18, 2023

The if exists is there.

When I replace the file_exists function with your suggestion, deleting the file works 🙏

I do see 3 cmd.exe popups when it deletes the file. The other working solution "only" has 2.

The ideal solution does not have any popups. But obviously that's just a nice-to-have.

@surrim
Copy link
Owner

surrim commented Jun 18, 2023

Included in 6f5f276

3 popups are perfect, if it's not from 3 attempts to delete the file.
Normally the popups are

  1. check if the file exists before (e.g. not working for unicode files)
  2. the del command
  3. check if the file exists after

It would be much easier if del would return a proper exitcode. On Linux you don't see popups at all. The best solution would be to use Lua's os.remove() command - but unfortunately it can't handle unicode filenames.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants