Giter Site home page Giter Site logo

Comments (15)

surrim avatar surrim commented on June 24, 2024 1

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.

from vlc-delete.

surrim avatar surrim commented on June 24, 2024

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

from vlc-delete.

fun29 avatar fun29 commented on June 24, 2024

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.

from vlc-delete.

surrim avatar surrim commented on June 24, 2024

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.

from vlc-delete.

fun29 avatar fun29 commented on June 24, 2024

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

from vlc-delete.

fun29 avatar fun29 commented on June 24, 2024

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'

from vlc-delete.

fun29 avatar fun29 commented on June 24, 2024

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'

from vlc-delete.

fun29 avatar fun29 commented on June 24, 2024

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'

from vlc-delete.

fun29 avatar fun29 commented on June 24, 2024

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)

from vlc-delete.

fun29 avatar fun29 commented on June 24, 2024

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 🙏

from vlc-delete.

surrim avatar surrim commented on June 24, 2024

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.

from vlc-delete.

fun29 avatar fun29 commented on June 24, 2024

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'

from vlc-delete.

surrim avatar surrim commented on June 24, 2024

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.

from vlc-delete.

fun29 avatar fun29 commented on June 24, 2024

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.

from vlc-delete.

surrim avatar surrim commented on June 24, 2024

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.

from vlc-delete.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.