From c702bdeda24205edd013806308344c7bdea84450 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Fri, 24 Aug 2018 08:02:22 +0200
Subject: [PATCH] client/console: don't fail writing history file when ~ is
 deleted

/reviewed-on https://lab.nexedi.com/nexedi/slapos.core/merge_requests/52
---
 slapos/client.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/slapos/client.py b/slapos/client.py
index 17e852f4d..cc7864624 100644
--- a/slapos/client.py
+++ b/slapos/client.py
@@ -139,7 +139,8 @@ def do_console(local):
     historyPath = os.path.expanduser("~/.slapconsolehistory")
 
     def save_history(historyPath=historyPath):
-      readline.write_history_file(historyPath)
+      if os.path.exists(os.path.dirname(historyPath)):
+        readline.write_history_file(historyPath)
     if os.path.exists(historyPath):
       readline.read_history_file(historyPath)
     atexit.register(save_history)
-- 
2.30.9