From 1c18fab68edc2a7aa6a1a32f1597e5b01be7c193 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Thu, 21 May 2020 23:31:07 +0200 Subject: [PATCH] Also chmod the directory for CrossProcessFileBasedSemaphore --- .../Helpers/CrossProcessFileBasedSemaphore.cs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs b/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs index 6fd589f35..8be08adbb 100644 --- a/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs +++ b/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs @@ -153,14 +153,34 @@ namespace ArchiSteamFarm.Helpers { } private void EnsureFileExists() { - Directory.CreateDirectory(Path.GetDirectoryName(FilePath)); - FileInfo fileInfo = new FileInfo(FilePath); if (fileInfo.Exists) { return; } + string directoryPath = Path.GetDirectoryName(FilePath); + + if (string.IsNullOrEmpty(directoryPath)) { + ASF.ArchiLogger.LogNullError(nameof(directoryPath)); + + return; + } + + DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath); + + if (!directoryInfo.Exists) { + Directory.CreateDirectory(directoryPath); + + if (OS.IsUnix) { + OS.UnixSetFileAccess(directoryPath, OS.EUnixPermission.Combined777); + } else { + DirectorySecurity directorySecurity = new DirectorySecurity(FilePath, AccessControlSections.All); + + directoryInfo.SetAccessControl(directorySecurity); + } + } + try { using (new FileStream(FilePath, FileMode.CreateNew)) { }