[vlc-commits] vlsub: fixes creation of cache directory if it doesn't exist

Aakash Singh git at videolan.org
Tue Aug 25 00:02:49 CEST 2020


vlc/vlc-3.0 | branch: master | Aakash Singh <17aakashsingh1999 at gmail.com> | Tue Mar 26 18:34:57 2019 +0530| [b686787c83550ab28f53244a936a86504cced637] | committer: Pierre Ynard

vlsub: fixes creation of cache directory if it doesn't exist

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.

Fixes #21595
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

(cherry picked from commit 583dded749fb3078a8cad495efcd5f4bcef0a875)
Signed-off-by: Pierre Ynard <linkfanel at yahoo.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=b686787c83550ab28f53244a936a86504cced637
---

 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 7580387ac9..066b9a9477 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 doesn'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(



More information about the vlc-commits mailing list