From 4c9099a79b2f93813d6d424126cb2f0a11da493a Mon Sep 17 00:00:00 2001 From: Vladimir Iakovlev Date: Mon, 19 Mar 2018 22:41:38 +0100 Subject: [PATCH] #N/A: Fix mmap log cleanup --- thefuck/entrypoints/shell_logger.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/thefuck/entrypoints/shell_logger.py b/thefuck/entrypoints/shell_logger.py index 3df3f76..584b550 100644 --- a/thefuck/entrypoints/shell_logger.py +++ b/thefuck/entrypoints/shell_logger.py @@ -16,9 +16,11 @@ def _read(f, fd): try: f.write(data) except ValueError: - f.move(0, const.LOG_SIZE_TO_CLEAN, - const.LOG_SIZE_IN_BYTES - const.LOG_SIZE_TO_CLEAN) - f.seek(const.LOG_SIZE_IN_BYTES - const.LOG_SIZE_TO_CLEAN) + position = const.LOG_SIZE_IN_BYTES - const.LOG_SIZE_TO_CLEAN + f.move(0, const.LOG_SIZE_TO_CLEAN, position) + f.seek(position) + f.write(b'\x00' * const.LOG_SIZE_TO_CLEAN) + f.seek(position) return data