Skip to content

Commit

Permalink
intf: Windows: manage Universal Naming Convention paths
Browse files Browse the repository at this point in the history
When a network drive is not mapped to a drive letter on Windows,
the path will appear as an UNC path starting with 'file://'.
However, Lua will fail to open that file to resolve the hash.
This thus fixes that problem by changing the protocol from 'file'
to 'unc' in order to avoid trying to resolve the hash when
reading a media from an UNC path.

Relates to #115

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
  • Loading branch information
XaF committed Jun 14, 2018
1 parent 4cbec8c commit 9b9d57c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions trakt.lua
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1905,10 +1905,20 @@ function get_current_info()
uri_proto = 'file' uri_proto = 'file'
uri_path = infos['uri'] uri_path = infos['uri']
elseif uri_proto == 'file' and elseif uri_proto == 'file' and
uri_path:sub(1,1) == '/' and
ospath.sep == '\\' then ospath.sep == '\\' then
-- On Windows, remove leading slash for file URIs if uri_path:sub(1,1) == '/' then
uri_path = uri_path:sub(2) -- On Windows, remove leading slash for file URIs
uri_path = uri_path:sub(2)
elseif string.match(uri_path, '^[a-zA-Z0-9][a-zA-Z0-9]+/') then
-- If the resolved path is an UNC path (starting by the
-- network drive name), change the uri_proto to unc to
-- specify that we will not try and resolve the media hash
vlc.msg.info('Media path is in the form of the Universal ' ..
'Naming Convention; Map the drive to a drive ' ..
'letter in order for the media hashes to be ' ..
'resolved.')
uri_proto = 'unc'
end
end end


cache[infos['key']].uri_proto = uri_proto cache[infos['key']].uri_proto = uri_proto
Expand Down

0 comments on commit 9b9d57c

Please sign in to comment.