Skip to main content

File Guard and Large File Guard for preserving file content

Project description

File Guard and Large File Guard

support for preserving the old content of a file. support for large files provide access via seek() to a specific file position.

use in own code

use with context and rollback() to rewind the changes done. exiting the context without raising an error or closing the file will commit the changes to the file finally.

when to use in own code

there are some typical use cases, such as:

  • in test scenarios when you need to rollback for the next test case
  • when writing changed config files from your code (falls back to old state)
  • when randomly accessing larger files in binary mode

find some code in github repo

code for small files

for small files FileGuard makes a copy using a TemporaryFile. in error case or when calling rollback() the file is copied back.

refer to sample()

code for large files

for large files LargeFileGuard provides methods like seek() and tell() to set the file pointer position. when writing to LargeFileGuard it preserves the content of the underlying file by writing to a journal or "before-image" file (also known as copy-on-write). in error case or by calling rollback() the changes are rewinded.

refer to sample2()

code for belated rollback

in case the rollback of an existing bim file needs to be done at a later point of time

refer to sample3()

code for multiple file rollback

in case rollback multiple files is needed - even if some files are already commited -

refer to sample4(), and sample5()

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfileguard-0.0.4.linux-x86_64.tar.gz (9.4 kB view hashes)

Uploaded source

Built Distribution

pyfileguard-0.0.4-py3-none-any.whl (6.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page