← Back to team overview

kicad-developers team mailing list archive

KICAD_CACHE_HOME environment variable

 

Attached is a patch to use a new KICAD_CACHE_HOME environment variable to set a custom path for the lockfiles on all platforms. It's tested under Windows and works as expected.

From 7f4245b0e2eacdeaa01d5cd753de5dfdcd28360c Mon Sep 17 00:00:00 2001
From: mwayne <wodarczykmike@xxxxxxxxx>
Date: Mon, 7 May 2018 13:46:33 +0200
Subject: [PATCH] Make lockfile path adjustable.

Use KICAD_CACHE_HOME environment variable on all platforms so users can specify a custom cache path.
---
 common/lockfile.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/common/lockfile.cpp b/common/lockfile.cpp
index 92ee0bd..baae3eb 100644
--- a/common/lockfile.cpp
+++ b/common/lockfile.cpp
@@ -86,12 +86,18 @@ wxString GetKicadLockFilePath()
     lockpath.AppendDir( "kicad" );
 #endif
 
-#if defined( __WXMAC__ ) || defined( __UNIX__ )
+    // Use KICAD_CACHE_HOME to allow the user to force a specific cache path.
+    if( wxGetEnv( wxT( "KICAD_CACHE_HOME" ), &envstr ) && !envstr.IsEmpty() )
+    {
+        // Override the assignment above with KICAD_CACHE_HOME
+        lockpath.AssignDir( envstr );
+    }
+
     if( !lockpath.DirExists() )
     {
         // Lockfiles should be only readable by the user
         lockpath.Mkdir( 0700, wxPATH_MKDIR_FULL );
     }
-#endif
+
     return lockpath.GetPath();
 }
-- 
2.11.1.windows.1


Follow ups