Skip to content

Commit d862f5a

Browse files
committed
Merge pull request scrapy#1297 from darkrho/leveldb-compact
Do leveldb compactation for httpcache on closing.
2 parents aaaba9f + 877c257 commit d862f5a

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)