Skip to content

Commit 877c257

Browse files
committed
Do leveldb compactation for the httpcache on closing.
1 parent 5bd0395 commit 877c257

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

scrapy/extensions/httpcache.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ def open_spider(self, spider):
302302
self.db = self._leveldb.LevelDB(dbpath)
303303

304304
def close_spider(self, spider):
305+
# Do compactation each time to save space and also recreate files to
306+
# avoid them being removed in storages with timestamp-based autoremoval.
307+
self.db.CompactRange()
305308
del self.db
306309

307310
def retrieve_response(self, spider, request):

0 commit comments

Comments
 (0)