Fix direct sql query for directories to the archive
Duplicated entries are now filtered by a SELECT DISTINCT clause.