From 9b9d57c020e84ac3faf8c2918878e75d57e96258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Beamonte?= Date: Wed, 13 Jun 2018 20:35:39 -0400 Subject: [PATCH] intf: Windows: manage Universal Naming Convention paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- trakt.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/trakt.lua b/trakt.lua index 7ddba2d..47f98ca 100644 --- a/trakt.lua +++ b/trakt.lua @@ -1905,10 +1905,20 @@ function get_current_info() uri_proto = 'file' uri_path = infos['uri'] elseif uri_proto == 'file' and - uri_path:sub(1,1) == '/' and ospath.sep == '\\' then - -- On Windows, remove leading slash for file URIs - uri_path = uri_path:sub(2) + if uri_path:sub(1,1) == '/' then + -- 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 cache[infos['key']].uri_proto = uri_proto