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

Aakash Singh 17aakashsingh1999 at gmail.com
Tue Mar 26 12:32:46 CET 2019


I did submit a patch earlier which tried to resolve the same problem but
inside the vlc core to which remi said it should be handled by the caller
to vlc_cachedir(). Hence, I made the necessary changes and shifted it to
VLSub.
I think it should be handled by the core itself because what use is a cache
dir if it doesnt already exist.

The two loops can be factored into one. Once the above discussion is done i
will make the necessary changes and send in another patch to solve this
problem.
Regards
Blurrrb

On Mon, 25 Mar 2019, 23:15 Aakash Singh, <17aakashsingh1999 at gmail.com>
wrote:

> Hey everyone
> Someone please review this patch. It was submitted a week ago and hasn't
> been reviewed yet.
>
> Regards
> Aakash Singh
>
> On Tue, Mar 19, 2019 at 6:11 PM Aakash Singh <17aakashsingh1999 at gmail.com>
> wrote:
>
>> The patch fixes creation of a cache directory for VLSub if it doesn't
>> already exist. The patch is working correctly. If the directory already
>> exists then vlc.io.mkdir() simply returns -1 indicating that the directory
>> already exists and no changes were made to the folder structure.
>> ---
>>  share/lua/extensions/VLSub.lua | 17 +++++++++++++++++
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/share/lua/extensions/VLSub.lua
>> b/share/lua/extensions/VLSub.lua
>> index ee9e5f84a9..64013ae46a 100644
>> --- a/share/lua/extensions/VLSub.lua
>> +++ b/share/lua/extensions/VLSub.lua
>> @@ -1488,6 +1488,23 @@ function download_subtitles()
>>
>>    subfileName = subfileName.."."..item.SubFormat
>>    local tmp_dir = vlc.config.cachedir()
>> +  -- create the cache directory if it doens't already exist
>> +  if package.config:sub(1, 1):match("/") then
>> +    -- unix based systems
>> +    local current_dir = "/"
>> +    for dir in tmp_dir:gmatch("[^/]+") do
>> +      current_dir = current_dir.."/"..dir
>> +      vlc.io.mkdir(current_dir, "0700")
>> +    end
>> +  else
>> +    -- windows systems
>> +    local current_dir = ""
>> +    for dir in tmp_dir:gmatch("[^\\]+") do
>> +      current_dir = current_dir.."\\"..dir
>> +      vlc.io.mkdir(current_dir, "0700")
>> +    end
>> +  end
>> +
>>    local file_target_access = true
>>
>>    local tmpFileName = dump_zip(
>> --
>> 2.19.1
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190326/4b53574f/attachment.html>


More information about the vlc-devel mailing list