fts: do not exhaust memory when processing million-entry directories