aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/addons
diff options
context:
space:
mode:
authorHenrique <typoon@gmail.com>2019-11-23 16:31:21 -0500
committerHenrique <typoon@gmail.com>2019-11-23 16:31:21 -0500
commit6d67286bd1e68b12fb1151cc6790e3a4bdadbe57 (patch)
tree7a4e351c54850377d66c8a353af1f33f476129e2 /mitmproxy/addons
parent01b40e2c36267db67b19ff6267b5ae3fc8d0ad24 (diff)
downloadmitmproxy-6d67286bd1e68b12fb1151cc6790e3a4bdadbe57.tar.gz
mitmproxy-6d67286bd1e68b12fb1151cc6790e3a4bdadbe57.tar.bz2
mitmproxy-6d67286bd1e68b12fb1151cc6790e3a4bdadbe57.zip
Fix to check if command_history file exists prior to trying to read it
Diffstat (limited to 'mitmproxy/addons')
-rw-r--r--mitmproxy/addons/command_history.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/mitmproxy/addons/command_history.py b/mitmproxy/addons/command_history.py
index 2c348d1e..113af213 100644
--- a/mitmproxy/addons/command_history.py
+++ b/mitmproxy/addons/command_history.py
@@ -7,6 +7,7 @@ import mitmproxy.options
import mitmproxy.types
from mitmproxy import command
+from mitmproxy import ctx
from mitmproxy.tools.console.commander.commander import CommandBuffer
@@ -22,8 +23,10 @@ class CommandHistory:
self.filtered_commands: typing.Deque[str] = collections.deque()
self.filter_active: bool = True
- _command_history_path = os.path.join(os.path.expanduser(mitmproxy.options.CONF_DIR), 'command_history')
- _history_lines = open(_command_history_path, 'r').readlines()
+ _command_history_path = os.path.join(os.path.expanduser(ctx.options.confdir), 'command_history')
+ _history_lines = []
+ if os.path.exists(_command_history_path):
+ _history_lines = open(_command_history_path, 'r').readlines()
self.command_history_file = open(_command_history_path, 'w')