UnwrittenFiles

Outputs only those documents that have not yet been written to the file system.
The constructors and file resolution logic follows the same semantics as Wyam.Core.Modules.IO.WriteFiles. This module is useful for eliminating documents from the pipeline on subsequent runs depending on if they've already been written to disk. For example, you might want to put this module right after Wyam.Core.Modules.IO.ReadFiles for a pipeline that does a lot of expensive image processing since there's no use in processing images that have already been processed. Note that only the file name is checked and that this module cannot determine if the content would have been the same had a document not been removed from the pipeline. Also note that you should only use this module if you're sure that no other pipelines rely on the output documents. Because this module removes documents from the pipeline, those documents will never reach the end of the pipeline and any other modules or pages that rely on them (for example, an image directory) will not be correct.

Usage

  • UnwrittenFiles()

    Writes the document content to disk with the same file name and relative path as the input file. This requires metadata for RelativeFilePath to be set (which is done by default by the Wyam.Core.Modules.IO.ReadFiles module).

  • UnwrittenFiles(DocumentConfig path)

    Uses a delegate to describe where to write the content of each document. The output of the function should be either a full path to the disk location (including file name) or a path relative to the output folder.

    • path

      A delegate that returns a string with the desired path.

  • UnwrittenFiles(string extension)

    Writes the document content to disk with the specified extension with the same base file name and relative path as the input file. This requires metadata for RelativeFilePath to be set (which is done by default by the Wyam.Core.Modules.IO.ReadFiles module).

    • extension

      The extension to use for writing the file.

Fluent Methods

Chain these methods together after the constructor to modify behavior.

  • Append(bool append = true)

    Appends content to each file instead of overwriting them.

    • append

      Appends to existing files if set to true.

  • IgnoreEmptyContent(bool ignoreEmptyContent = true)

    Ignores documents with empty content, which is the default behavior.

    • ignoreEmptyContent

      If set to true, documents with empty content will be ignored.

  • OnlyMetadata(bool onlyMetadata = true)

    Indicates that only metadata should be added to the document and a file should not actually be written to the file system. This is useful for preprocessing documents so they appear in a pipeline with the correct write metadata, while actually writing them later with a second Wyam.Core.Modules.IO.WriteFiles module invocation. Only the following metadata values are written when this flag is turned on: WritePath, RelativeFilePath, RelativeFilePathBase, and RelativeFileDir. The Destination... metadata values are not added to the document when only setting metadata..

    • onlyMetadata

      If set to true, metadata will be added to the input document(s) without actually writing them to the file system.

  • UseWriteMetadata(bool useWriteMetadata = true)

    By default the metadata values for WritePath, WriteFileName, and WriteExtension are checked and used first, even if a delegate is specified in the constructor. This method can be used to turn off the default behavior and always rely on the delegate for obtaining the write location.

    • useWriteMetadata

      If set to false, metadata of the input document will not be used.

  • Where(DocumentConfig predicate)

    Specifies a predicate that must be satisfied for the file to be written.

    • predicate

      A predicate that returns true if the file should be written.

GitHub