Use storage_mtime when determining if we can reuse cached data while scanning

Backport to stable6 of the following commits, in order:
- 203d5d0
- 4113042
- 7e4c80f
- 16b898d