# HG changeset patch # User Marcin Kuzminski # Date 2018-04-18 15:50:32 # Node ID 01439ec40403baf1ceddcddeb3d07479aa2262f7 # Parent 33739db875cfba76d6b1eb570c0f59841489a5e8 diff-cache: use bz2 to reduce diff-cache size. diff --git a/rhodecode/lib/diffs.py b/rhodecode/lib/diffs.py --- a/rhodecode/lib/diffs.py +++ b/rhodecode/lib/diffs.py @@ -25,11 +25,12 @@ Set of diffing helpers, previously part import os import re +import bz2 + import collections import difflib import logging import cPickle as pickle - from itertools import tee, imap from rhodecode.lib.vcs.exceptions import VCSError @@ -1142,7 +1143,7 @@ def cache_diff(cached_diff_file, diff, c } try: - with open(cached_diff_file, 'wb') as f: + with bz2.BZ2File(cached_diff_file, 'wb') as f: pickle.dump(struct, f) log.debug('Saved diff cache under %s', cached_diff_file) except Exception: @@ -1168,7 +1169,7 @@ def load_cached_diff(cached_diff_file): data = None try: - with open(cached_diff_file, 'rb') as f: + with bz2.BZ2File(cached_diff_file, 'rb') as f: data = pickle.load(f) log.debug('Loaded diff cache from %s', cached_diff_file) except Exception: