move check if a file should be encrypted to the pre hook

move check if a file should be encrypted to the pre hook, this way we should avoid opening a file a second time if it is already open, see https://github.com/owncloud/core/issues/5950#issuecomment-38787682

@PVince81 I tested the changes here with local storage and my FTP server. Can you give it a try with vsftpd? Thanks!