VersionedFileSystem
Description
- Derived from
-
FileSystem abstract
A versioned file system.
The VersionedFileSystem is an implementation of the IFileSystem interface that provides a read-only view into a virtual filesystem, which based on a versioned content repository, see Repository). Please be aware that this class does not implement a version control system (like Git or SVN). Instead, it provides a simple mechanism for building a versioned filesystem and accessing files for individual versions.
Public / Constructors
VersionedFileSystem
Creates a new instance of VersionedFileSystem.
The Refresh method will be called lazily upon the first filesystem access. To catch potential filesystem errors early, it may also be called right after creating a VersionedFileSystem object.
Public / Methods
Commit
Updates the metadata of the versioned filesystem and optionally creates a new version based on the given content.
Calling this method may cause write accesses into Repository. In all other cases, the VersionedFileSystem class performs read-only accesses. If CanCommit returns false, this method will always throw.
- IOException
-
If an I/O error has occurred.
- See also
Refresh
Refreshes the metadata of this versioned filesystem.
The refreshed metadata is kept in memory. To write the metadata files, call Commit, passing null.
- IOException
-
If an I/O error has occurred.
- See also
Public / Attributes
Repository
Returns the storage repository of this versioned file system.
The storage repository is populated with content using the following directory structure:
-
0/
The special version0holds the temporary version that has not yet been assigned a version number because it is still being processed by Commit. -
N/
For each versionN(always greater than or equal to1), a corresponding directory in the repository holds only the content that is different from the previous version.
A version N stores only the differences to its previous version N-1. When a file is requested for version N, the following logic is used to find the content file in the repository:
-
If a content file exists in the version directory, use that file. Otherwise, continue with 2.
-
If a deletion placeholder for the content file exists in the version directory, fail with a IOError.NotFound error. Otherwise, continue with 3.
-
If
N = 1, fail with a IOError.NotFound error. Otherwise, continue with 4. -
Set
NtoN - 1and continue with 1.
A deletion placeholder is a file with the same name but prefixed with '!'. This implies that regular content files with such a name cannot be used. The presence of a directory for version N is determined by whether it contains at least one file of the same version, which means that empty directories cannot be used.
Version
Returns the current version of the filesystem.
The version increases when Commit is called and one or more file changes have occurred.
- IOException
-
If an I/O error has occurred.
- See also