Automated recovery file library
Project description
Part of the Using JSON Schema project.
Robust storage using text files is enhanced with support for automated recovery should an update fail.
This library provides support for reading and writing files in a recoverable mode, allowing automated recovery when the program restarts. Normal file read / write is also supported, enabling a common interface for both files using automated recovery capabilities and those not using them.
API
readFile
Read a file synchronously from a file system.
readFile (filename)
data = readFile (filename)
writeFile
Write a file synchronously to a file system.
writeFile (filename, data)
writeFile (filename, data)
safeReadFile
Read a file synchronously from a file system, inspecting the file system state and performing recovery processing if needed.
safeReadFile (filename)
data = safeReadFile (filename)
safeWriteFile
Write data to a file synchronously, using a recoverable set of steps. Should the write processing fail to complete, auto-recovery can perform the steps required to bring the file content back to a stable state.
safeWriteFile (filename, data)
safeWriteFile (filename, data)
safeGetState
Get the current state of the set of files representing the current file system contents. Returns one of,
SAFE_NORMAL, normal state, base and backup files only present
SAFE_RECOVERABLE, partial write condition that is automatically recoverable the next time a read, write or recover function is called
SAFE_INTERVENE, last write failed before the data being written reached a recoverable state. Manual intervention is required if recovery of the last write is required, otherwise auto-recovery will recover to the prior stable state.
safeGetState (filename)
state = safeGetState (filename)
safeRecover
Initiate the auto-recovery process. This follows the same steps as safeReadFile follows, but can be called independently.
safeRecover (filename)
safeRecover (file)
SafeFileError
SafeFileError (code, message)
Constants for the error codes,
NO_ERROR
INVALID_NAME
DOES_NOT_EXIST
IS_NOT_A_FILE
READ_ERROR
WRITE_ERROR
SAFE_NORMAL
SAFE_RECOVERABLE
SAFE_INTERVENE
Installation
The program can be installed using pip, with the command,
pip install ujs-safefile
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ujs-safefile-0.1.0.zip
.
File metadata
- Download URL: ujs-safefile-0.1.0.zip
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1c0fe68c0456bb5454d7df750121d8719f47c5e7871ccea755e11f6a414e0be |
|
MD5 | d0694e1b670a082b1e5a6b25d677ceee |
|
BLAKE2b-256 | 525ff8c8a0d1db7a8af5fecdf2bcaeeb9c76146524f2e2b9e4a5841977c0ff84 |