[1.7.x] Fixed #22681 -- Made TarArchive recognize leading directories properly.

Backport of 083d285b82 from master