Fixes #4516 file module: check prev_state earlier and use that if state is not specified