LogoLogo
HomePricingDocumentation
  • 💿Getting Started
    • Installation and Project Setup
    • Hello Perigee!
    • Perigee Application Design
    • Hello Configuration
    • Hello Logs
    • Hello Integration
    • Troubleshooting
    • Case Studies
  • 📃License + Notice
    • 📂Licensing
    • Notice of Third Party Agreements
  • 🚀Perigee and Beyond
    • Extending - Threads
    • Extending - Loaders
    • ⏳All about CRON
  • 🔮API Generation
    • What is API Generation?
    • API Builder
  • 🗺️Architecting YOUR App
    • Design and Requirements
    • Define Sources
    • Requirements
  • 🧩Core Modules
    • 🌐PerigeeApplication
    • 🪡Thread Registry
    • Event Sources
      • Scheduled/Logic
        • CRON Thread
        • Scheduler
        • Sync Agent
      • Watchers
        • SalesForce
        • Sharepoint
        • Directory Watch
        • Directory Notifier
        • IMAP
    • Credential Management
      • Connection Strings
      • Custom Refresh Logic
      • RestSharp Authenticator
      • Credential Store SDK
      • ⁉️Troubleshooting Credentials
    • Integration Utilities
      • HTTP(S) - RestSharp
      • Transaction Coordinator
      • Limiter
      • Watermarking
    • Alert Managers
      • SMS
      • Email
      • Discord
      • Teams
    • File Formats
      • Excel
      • CSV
    • 📁File System Storage
      • File Revision Store
      • Concurrent File Store
      • FileSync + Cache
    • Third Party
      • SmartSheets
      • Microsoft Graph
    • Perigee In Parallel
      • Parallel Processing Reference
      • Extensions
      • GroupProcessor
      • SingleProcessor
    • 🧱Utility Classes
      • Metrics
      • F(x) Expressions
      • Multi-Threaded Processor (Scatter Gather)
      • OpenAI - GPT
      • XML Converter
      • Dynamic Data Table
      • Debounce
      • Thread Conditions
      • Perigee Utility Class
      • Network Utility
      • Lists
      • FileUtil
      • Inclusive2DRange
      • Strings, Numbers, Dates
      • Nested Sets
      • Behavior Trees
      • JsonCompress
      • Topological Sorting
      • DBDownloader
    • 🈁Bit Serializer
  • 📣Examples and Demos
    • API + Perigee
    • 📰Excel Quick Load
    • SalesForce Watcher
    • Report Scheduler
    • Agent Data Synchronization
    • 📩IMAP Echo bot
    • Watch and load CSVs
    • Graph Delegated Authorization + DataVerse
    • Coordinator Demo
    • Azure Service Bus
    • QuickBooks Online
  • 📘Blueprints
    • Perigee With .NET Hosting
    • Web Host Utilities
    • 🔌Plugin Load Context
  • 🎞️Transforms
    • 🌟What is Transforms?
    • 📘Terminology
    • 🦾The Mapping Document
    • 👾Transformation Process
    • 😎Profile
    • 🎒Automation
      • 🕓Package Options
      • 🔳Configuration
    • 🔧Utilities
      • 🧹Clean
      • 📑Map File
      • 🔎File Identification
      • 🗺️Map Generation
      • 🪅Insert Statement Generation
  • 🗃️Transform SDK
    • 👋Quick Start Guide
    • 🥳MapTo
    • 🔌Authoring Plugins
      • 🔘File IO Process
      • 📢Data Quality
      • 🟢Transform Process
    • SDK Reference
      • 🔘FileIOProcessData
      • 📢DataQualityContext
      • 🎛️TransformDataContext
      • 🏅TransformResult
Powered by GitBook
On this page
  • SaveFile
  • ReadFile Method
  • UpdateFile Method
Export as PDF
  1. Core Modules
  2. File System Storage

File Revision Store

FileRevisionStore class handles file revision storage. It caters for concurrent safe read/write operations across the entire application using a globally unique thread-safe lock. This class also offers the following features:

  • File verification processing

  • Data file versioning with a system-level transactional replace to prevent partial file writes or data corruption

  • Ability to rewind corrupt files back to a previous version when verification fails

  • An UpdateFile method that performs a thread-locked read/write on the same transaction

The "revision checked" feature serves as a safety mechanism in the FileRevisionStore, ensuring the integrity of the files written to disk. Before overwriting, each file is assigned a revision, and the bytes are transactionally verified to prevent partial or corrupt file writes. This meticulous verification process safeguards the data by confirming that only complete and accurate revisions are written, thus minimizing the risk of data corruption or loss due to incomplete or erroneous file writes.

SaveFile

This method saves a file and returns a boolean value indicating if the operation was successful.

  • The Path is supplied to where the file is stored.

  • A byte array is passed of the data to store

  • A Verification function is optionally supplied to verify the data written to disk.

In the example below, we're writing data using JsonCompress. The verification function is simply checking that we can decompress the bytes again from disk.

Example:

bool isSaved = FileRevisionStore.SaveFile("data.bin", 
    JsonCompress.Compress(new BitPerson() { Name = "Bit Bob", PersonType = BitPersonType.adult }), 
    (b) => { 
        var d = JsonCompress.Decompress<BitPerson>(b);
        return true;
});

ReadFile Method

ReadFile method reads a file and performs verification.

  • The Path is supplied to where the file is stored.

  • An out boolean is sent back saying whether or not the validation was a failure.

  • A Verification function is optionally supplied to verify the data read back from the disk.

In the below example, we are using JsonCompress to verify the data can be decompressed from disk without an exception thrown.

Example:

byte[] ReadBytes = FileRevisionStore.ReadFile("data.bin", out var validationFailed,
    (b) => {
        var d = JsonCompress.Decompress<BitPerson>(b);
        return true;
});

UpdateFile Method

UpdateFile method performs a thread-locked read/write operation on the same transaction.

It's very similar to the above two methods:

  • The Path is supplied to where the file is stored.

  • An out boolean is sent back saying whether or not the validation was a failure.

  • A callback with the bytes being read is supplied, this is how you update the file

  • A Verification function is optionally supplied to verify the data read back from the disk.

    • This is actually called twice in the update cycle. Once on file read, and a second time on file write.

Example:

FileRevisionStore.UpdateFile("data.bin",
    out bool validationfailed,
    (byteIn) =>
    {
        var d = JsonCompress.Decompress<BitPerson>(byteIn);
        d.PersonType = BitPersonType.child;
        return JsonCompress.Compress(d);
    },
    (b) =>
    {
        var d = JsonCompress.Decompress<BitPerson>(b);
        return true;
}); 
PreviousFile System StorageNextConcurrent File Store

Last updated 9 months ago

🧩
📁
Page cover image