delete_file: fix for files not deleted on end of playlist

Currently, the selected files are deleted only when mpv is
exited via the quit command. If, however, the quit reason is
eof of the last file in the playlist, delete_file would not
delete any files.

To fix this use the correct event, i.e. shutdown, instead of
end-file.

See:

https://github.com/mpv-player/mpv/blob/master/DOCS/man/lua.rst#list-of-events
This commit is contained in:
Svetlin Ankov 2018-04-09 22:13:05 +03:00
parent 4c023ed7ea
commit 50a3f36c92
1 changed files with 5 additions and 7 deletions

View File

@ -29,14 +29,12 @@ function mark_delete()
end
end
function delete(e)
if e.reason == "quit" then
for i, v in pairs(del_list) do
print("deleting: "..v)
os.remove(v)
end
function delete()
for i, v in pairs(del_list) do
print("deleting: "..v)
os.remove(v)
end
end
mp.add_key_binding("ctrl+DEL", "delete_file", mark_delete)
mp.register_event("end-file", delete)
mp.register_event("shutdown", delete)