"Aware as he was of his duties and her character he should have investigated her telephone in far greater detail than he did. He appears to have had a limited grasp of his responsibilities as disclosure officer. There is no evidence that he consulted the Crown Prosecution Service about any material he had doubts about.”

Three days before the trial was due to start, Det Con Lewis told the Crown Prosecution Service that "nothing of relevance had emerged" from a search of the telephone.

"This was a truly startling state of affairs," the judge said. "Had not the applicants carried out a thorough investigation of the telephone a much skewed picture would have been presented to the jury."

Thady Duff, Leo Mahon and Patrick Foster, all 22, and James Martin, 20, claimed the woman was a willing sex partner at the time of the alleged rape after the annual college ball at the Royal Agricultural University in Cirencester, Gloucestershire in May 2014.

The trial was due to begin at Gloucester Crown Court in March, but after delays due to the late disclosure of evidence and a review of the case, the prosecution offered no evidence and the four defendants were cleared.

Afterwards the defendants' barristers criticised Det Con Lewis for "cherry picking" supportive evidence and "airbrushing out of the picture" anything that could have helped the men.

This included text messages sent by the complainant in the hours after the alleged incident and a conversation with a friend about what would happen if the video became common knowledge.

It also emerged as the trial was due to begin that police failed to disclose that the complainant was a witness to an alleged rape on an army base in October 2014 and that there were inconsistencies in her evidence. The alleged rapist was a soldier but he was later cleared.

Three of the defendants, Mr Duff, Mr Mahon and Mr Foster, returned to court last month to apply for a proportion of their legal costs to be paid by the prosecution. Mr Martin received legal aid in the case.

They have been left with legal bills totalling £221,000 after hiring three QCs to lead the fight to clear their names.