Ejemplo n.º 1
0
        /// <summary>
        /// Reads in parallel all writes recorded in given sideband files (<paramref name="sidebandFiles"/>).
        /// The task of reading paths from a single sideband file is delegated to <see cref="SidebandReader.ReadSidebandFile"/>.
        /// Exceptions of type <see cref="IOException"/> and <see cref="BuildXLException"/> are caught, logged, and ignored.
        /// </summary>
        internal string[] TryReadAllRecordedWrites(IReadOnlyList <string> sidebandFiles)
        {
            try
            {
                return(sidebandFiles
                       .AsParallel(Context)
                       .SelectMany(tryReadSidebandFile)
                       .ToArray());
            }
            catch (OperationCanceledException)
            {
                // No specific handling needed for cancellations. Build session will terminate
                return(CollectionUtilities.EmptyArray <string>());
            }

            IEnumerable <string> tryReadSidebandFile(string filename)
            {
                try
                {
                    return(SidebandReader.ReadSidebandFile(filename, ignoreChecksum: true));
                }
                catch (Exception e) when(e is BuildXLException || e is IOException || e is OperationCanceledException)
                {
                    Processes.Tracing.Logger.Log.CannotReadSidebandFileWarning(LoggingContext, filename, e.Message);
                    return(CollectionUtilities.EmptyArray <string>());
                }
            }
        }
Ejemplo n.º 2
0
 private bool TryReadSidebandFile(string filename, out SidebandMetadata metadata, out IEnumerable <string> paths)
 {
     try
     {
         // We ignore the checksum because even when the sideband file is compromised,
         // it is possible to call <see cref="ReadRecordedPaths"/> which will then try to recover
         // as many recorded paths as possible.
         (paths, metadata) = SidebandReader.ReadSidebandFile(filename, ignoreChecksum: true);
         return(true);
     }
     catch (Exception e) when(e is BuildXLException || e is IOException || e is OperationCanceledException)
     {
         Processes.Tracing.Logger.Log.CannotReadSidebandFileWarning(LoggingContext, filename, e.Message);
         metadata = null;
         paths    = null;
         return(false);
     }
 }