<div dir="ltr"><div>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.</div><div>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.</div><div>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).<br></div><div dir="ltr">---<br> share/lua/extensions/VLSub.lua | 16 ++++++++++++++++<br> 1 file changed, 16 insertions(+)<br><br>diff --git a/share/lua/extensions/VLSub.lua b/share/lua/extensions/VLSub.lua<br>index ee9e5f84a9..7873272df1 100644<br>--- a/share/lua/extensions/VLSub.lua<br>+++ b/share/lua/extensions/VLSub.lua<br>@@ -1488,6 +1488,22 @@ function download_subtitles()<br> <br>   subfileName = subfileName.."."..item.SubFormat<br>   local tmp_dir = vlc.config.cachedir()<br>+  -- create the cache directory if it doens't already exist<br>+  local separator = ""<br>+  local current_dir = ""<br>+  if package.config:sub(1, 1):match("/") then<br>+    -- unix based systems<br>+    separator = "/"<br>+    current_dir = "/"<br>+  else<br>+    -- windows systems<br>+    separator = "\\"<br>+  end <br>+  for dir in tmp_dir:gmatch("[^"..separator.."]+") do<br>+    current_dir = current_dir..dir..separator<br>+    local vars = vlc.io.mkdir(current_dir, "0700")<br>+  end<br>+<br>   local file_target_access = true<br> <br>   local tmpFileName = dump_zip(<br>-- <br>2.19.1<br><br></div></div>