From 0a8982d05684cb4a9003debc21fe6a8be49bdcb3 Mon Sep 17 00:00:00 2001 From: Rich Sun Date: Mon, 7 Oct 2024 20:56:53 -0700 Subject: [PATCH] Specify file open permissions needed as read only. (Causing access failed in environments with strict read-only file system settings) --- LLama/Native/SafeLlamaModelHandle.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LLama/Native/SafeLlamaModelHandle.cs b/LLama/Native/SafeLlamaModelHandle.cs index 66f25bb36..4e49a34fc 100644 --- a/LLama/Native/SafeLlamaModelHandle.cs +++ b/LLama/Native/SafeLlamaModelHandle.cs @@ -129,7 +129,7 @@ public static SafeLlamaModelHandle LoadFromFile(string modelPath, LLamaModelPara // - File exists (automatically throws FileNotFoundException) // - File is readable (explicit check) // This provides better error messages that llama.cpp, which would throw an access violation exception in both cases. - using (var fs = new FileStream(modelPath, FileMode.Open)) + using (var fs = new FileStream(modelPath, FileMode.Open, FileAccess.Read)) if (!fs.CanRead) throw new InvalidOperationException($"Model file '{modelPath}' is not readable");