Fixed slug clashes when indexing a lot of files

When indexing a couple thousand files at once it might lead to duplicate slugs
and since the database transaction is just commited at the end the "check in db if slug exists" thing does not work.

I added committing every 10 directories when indexing which fixed the problem for me.