Merge pull request #1297 from darkrho/leveldb-compact

Do leveldb compactation for httpcache on closing.
This commit is contained in:
Daniel Graña 2015-06-12 11:16:16 -03:00
commit d862f5acff
1 changed files with 3 additions and 0 deletions

View File

@ -302,6 +302,9 @@ class LeveldbCacheStorage(object):
self.db = self._leveldb.LevelDB(dbpath)
def close_spider(self, spider):
# Do compactation each time to save space and also recreate files to
# avoid them being removed in storages with timestamp-based autoremoval.
self.db.CompactRange()
del self.db
def retrieve_response(self, spider, request):