private SftpATTRS changeToRepositoryDirectory( ChannelSftp channel, String dir, String filename )
throws ResourceDoesNotExistException, SftpException
{
// This must be called first to ensure that if the file doesn't exist it throws an exception
SftpATTRS attrs;
try
{
channel.cd( repository.getBasedir() );
if ( dir.length() > 0 )