GetCurrentIntermediateModelManifest() public method

public GetCurrentIntermediateModelManifest ( HostService hostService ) : ModelManifest
hostService HostService
return ModelManifest
Example #1
0
 public FileModel LoadIntermediateModel(IncrementalBuildContext incrementalContext, string fileName)
 {
     if (!CanIncrementalBuild)
     {
         return null;
     }
     var processor = (ISupportIncrementalDocumentProcessor)Processor;
     var cmm = incrementalContext.GetCurrentIntermediateModelManifest(this);
     string cfn;
     if (!cmm.Models.TryGetValue(fileName, out cfn))
     {
         throw new BuildCacheException($"Last build hasn't loaded model {fileName}");
     }
     using (var stream = File.OpenRead(Path.Combine(incrementalContext.BaseDir, cfn)))
     {
         return processor.LoadIntermediateModel(stream);
     }
 }
Example #2
0
        public void SaveIntermediateModel(IncrementalBuildContext incrementalContext)
        {
            if (!ShouldTraceIncrementalInfo)
            {
                return;
            }
            var processor = (ISupportIncrementalDocumentProcessor)Processor;
            var mi = incrementalContext.GetModelLoadInfo(this);
            var lmm = incrementalContext.GetLastIntermediateModelManifest(this);
            var cmm = incrementalContext.GetCurrentIntermediateModelManifest(this);

            foreach (var pair in mi)
            {
                IncrementalUtility.RetryIO(() =>
                {
                    string fileName = IncrementalUtility.GetRandomEntry(incrementalContext.BaseDir);
                    if (pair.Value == null)
                    {
                        if (lmm == null)
                        {
                            throw new BuildCacheException($"Full build hasn't loaded model {pair.Key}");
                        }
                        string lfn;
                        if (!lmm.Models.TryGetValue(pair.Key, out lfn))
                        {
                            throw new BuildCacheException($"Last build hasn't loaded model {pair.Key}");
                        }
                        File.Move(Path.Combine(incrementalContext.LastBaseDir, lfn), Path.Combine(incrementalContext.BaseDir, fileName));
                    }
                    else
                    {
                        var key = TypeForwardedToRelativePath.NormalizedWorkingFolder + pair.Key;
                        var model = Models.Find(m => m.Key == key);
                        using (var stream = File.Create(Path.Combine(incrementalContext.BaseDir, fileName)))
                        {
                            processor.SaveIntermediateModel(model, stream);
                        }
                    }
                    cmm.Models.Add(pair.Key, fileName);
                });
            }
        }