This program demonstrates the problem that @Titus_Anderson mentions. The counter should reset each time someone chooses files, and if you choose the same file twice in a row, it does not reset.
I gave that approach I mentioned a try in this commit. It is working with my example, but it’d be cool to get independent verification before publishing.