Even before East India Company, India faced several outsider attacks.
From Alexander the Great to various Khan's, then Mughals, then Portuguese etc.
Some important Indian texts were burned/destoryed in these attacks, For eg., the Nalanda University
Still, a lot of texts remained both in written format and in Oral format.
Nalanda U operated for 600 years from 427 CE (!!!) holding over 9m texts [2] The importance of texts from that generation at that scale cannot be overstated
Two more factors, India had contact with most of the world since the beginning, so no new disease wiped it on contact. Also you can not overestimate the population of India.
All thanks to the East India Company being a soulless megacorp devoted to profits instead of religious zeal like the other colonists.