Issue #3307478 by kunal.sachdev: Move code to copy files in active and stage directories in a separate function