aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/addons
diff options
context:
space:
mode:
authorHenrique <typoon@gmail.com>2019-11-27 09:21:30 -0500
committerHenrique <typoon@gmail.com>2019-11-27 09:21:30 -0500
commit8eb173b44e6c9fe093e58428dc6dd8d812b80318 (patch)
tree81edfc9ed337c18af1ec2935694f666f9dcd39c0 /mitmproxy/addons
parent863d2fbcb20b3f94df2ef2cf2478e86a736b7b65 (diff)
downloadmitmproxy-8eb173b44e6c9fe093e58428dc6dd8d812b80318.tar.gz
mitmproxy-8eb173b44e6c9fe093e58428dc6dd8d812b80318.tar.bz2
mitmproxy-8eb173b44e6c9fe093e58428dc6dd8d812b80318.zip
Fixed small bugs on command_history and tests
Diffstat (limited to 'mitmproxy/addons')
-rw-r--r--mitmproxy/addons/command_history.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/mitmproxy/addons/command_history.py b/mitmproxy/addons/command_history.py
index f86a6196..2c1bf887 100644
--- a/mitmproxy/addons/command_history.py
+++ b/mitmproxy/addons/command_history.py
@@ -33,11 +33,12 @@ class CommandHistory:
if "command_history" in updated or "confdir" in updated:
if ctx.options.command_history and self.history_file.is_file():
self.history = self.history_file.read_text().splitlines()
+ self.set_filter('')
def done(self):
if ctx.options.command_history and len(self.history) > self.VACUUM_SIZE:
# vacuum history so that it doesn't grow indefinitely.
- history_str = "\n".join(self.history[-self.VACUUM_SIZE/2:]) + "\n"
+ history_str = "\n".join(self.history[-self.VACUUM_SIZE / 2:]) + "\n"
self.history_file.write_text(history_str)
@command.command("commands.history.add")
@@ -49,6 +50,9 @@ class CommandHistory:
if ctx.options.command_history:
with self.history_file.open("a") as f:
f.write(f"{command}\n")
+ f.close()
+
+ self.set_filter('')
@command.command("commands.history.get")
def get_history(self) -> typing.Sequence[str]:
@@ -57,8 +61,10 @@ class CommandHistory:
@command.command("commands.history.clear")
def clear_history(self):
- self.history_file.unlink()
+ if self.history_file.exists():
+ self.history_file.unlink()
self.history = []
+ self.set_filter('')
# Functionality to provide a filtered list that can be iterated through.