[vlc-devel] [PATCH] Fixes #21595: VLSub: fixes creation of cache directory if it doesn't exist

Thomas Guillem thomas at gllm.fr
Fri Mar 29 13:22:21 CET 2019


Hello, thanks for the patch.
I merged it yesterday.

On Thu, Mar 28, 2019, at 03:50, Aakash Singh wrote:
> Bonjour Thomas
> Would you please review this patch? All changes you suggested have been made and an addition problem which caught my eye has been resolved(windows paths dont begin with \\).
> Regards
> Aakash Singh(Blurrrb)
> 
> On Tue, 26 Mar 2019, 18:16 Aakash Singh, <17aakashsingh1999 at gmail.com> wrote:
>> This patch fixes issue #21595. When VLSub asks for the cache directory and it doesn't exist an error is thrown. This patch makes sure that the directory is created before it is accessed for writing.
>> This patch works by splitting the directory path at the os specific separators and then constructing the patch sequence to cache directory step by step and creating the missing directories in the path.
>> This patch also handles unix absolute paths starting with "/" and windows paths which don't start with "\\" (\\C:\\users\\ is wrong, C:\\users\\ is correct).
>> ---
>>  share/lua/extensions/VLSub.lua | 16 ++++++++++++++++
>>  1 file changed, 16 insertions(+)
>> 
>> diff --git a/share/lua/extensions/VLSub.lua b/share/lua/extensions/VLSub.lua
>> index ee9e5f84a9..7873272df1 100644
>> --- a/share/lua/extensions/VLSub.lua
>> +++ b/share/lua/extensions/VLSub.lua
>> @@ -1488,6 +1488,22 @@ function download_subtitles()
>> 
>>  subfileName = subfileName.."."..item.SubFormat
>>  local tmp_dir = vlc.config.cachedir()
>> + -- create the cache directory if it doens't already exist
>> + local separator = ""
>> + local current_dir = ""
>> + if package.config:sub(1, 1):match("/") then
>> + -- unix based systems
>> + separator = "/"
>> + current_dir = "/"
>> + else
>> + -- windows systems
>> + separator = "\\"
>> + end 
>> + for dir in tmp_dir:gmatch("[^"..separator.."]+") do
>> + current_dir = current_dir..dir..separator
>> + local vars = vlc.io.mkdir(current_dir, "0700")
>> + end
>> +
>>  local file_target_access = true
>> 
>>  local tmpFileName = dump_zip(
>> -- 
>> 2.19.1
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190329/f944bc52/attachment.html>


More information about the vlc-devel mailing list