Fix leak when pack cache is rebuilt.