public async Task <Possible <string, Failure> > ProduceFileAsync( CasHash hash, string filename, FileState fileState, UrgencyHint urgencyHint, Guid activityId) { Contract.Requires(!IsClosed); Contract.Requires(filename != null); using (var counter = m_counters.ProduceFileCounter()) { using (var eventing = new ProduceFileActivity(BasicFilesystemCache.EventSource, activityId, this)) { eventing.Start(hash, filename, fileState, urgencyHint); try { FileUtilities.CreateDirectory(Path.GetDirectoryName(filename)); await m_cache.CopyFromCasAsync(hash, filename); counter.FileSize(new FileInfo(filename).Length); } catch (Exception e) { counter.Fail(); return(eventing.StopFailure(new ProduceFileFailure(CacheId, hash, filename, e))); } return(eventing.Returns(filename)); } } }