Browse Source

VLSub: Fix hash generation error handling

pull/69/head
Hugo Beauzée-Luyssen 8 years ago
parent
commit
914983b3fe
  1. 11
      share/lua/extensions/VLSub.lua

11
share/lua/extensions/VLSub.lua

@ -1297,21 +1297,24 @@ openSub = {
local data_end = "" local data_end = ""
local size local size
local chunk_size = 65536 local chunk_size = 65536
local ok
local err
-- Get data for hash calculation -- Get data for hash calculation
vlc.msg.dbg("[VLSub] Read hash data from stream") vlc.msg.dbg("[VLSub] Read hash data from stream")
local file = vlc.stream(openSub.file.uri) local file = vlc.stream(openSub.file.uri)
size = file:getsize()
data_start = file:read(chunk_size) data_start = file:read(chunk_size)
ok, size = pcall(file.getsize, file)
if not size then if not size then
vlc.msg.warn("[VLSub] Failed to get stream size") vlc.msg.warn("[VLSub] Failed to get stream size: " .. size )
setError(lang["mess_err_hash"]) setError(lang["mess_err_hash"])
return false return false
end end
if not file:seek( size - chunk_size ) then ok, err = pcall(file.seek, file, size - chunk_size)
vlc.msg.warn("[VLSub] Failed to seek to the end of the stream") if not ok then
vlc.msg.warn("[VLSub] Failed to seek to the end of the stream: " .. err)
setError(lang["mess_err_hash"]) setError(lang["mess_err_hash"])
return false return false
end end

Loading…
Cancel
Save