Fix cancellation of files (see #10984)

Cancel after scanning a folder, cancelling files directly.