Skip to content

A module that creates a patched levelDB instance that can be served simulataneous with the original levelDB

License

Notifications You must be signed in to change notification settings

RestoredCDC/Patch_LevelDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌺 RestoredCDC LevelDB Patch Tool

Python License Tests Lint


A command-line tool for patching, auditing, and managing LevelDB content, designed for the RestoredCDC project.


✨ Features

✅ Supports add, replace, and remove operations
✅ Handles both text and binary content
✅ Automatic audit logging (JSON Lines)
✅ Exports audit log as a simple HTML report
✅ Tracks MD5 checksums for every patch
✅ Patch reason and optional MIME type tracking
✅ Includes unit tests via pytest


📦 Requirements

Package Purpose
plyvel LevelDB bindings
pytest Testing
flake8 Linting
black Code formatting
isort Import sorting
flask + waitress Optional: serve patched content

🛠 Installation

pip install -r requirements.txt

Or manually:

pip install plyvel flask waitress pytest flake8 black isort

🚦 Usage

Apply a text patch

python cli.py apply-text --db path/to/patchdb --key mykey \
    --reason "Updated disclaimer text" --file disclaimer.txt \
    --mimetype text/plain

Apply a binary patch

python cli.py add-binary --db path/to/patchdb --key logo \
    --reason "Updated logo" --file logo.png \
    --mimetype image/png

Remove a patch (mode auto-detected)

python cli.py remove-patch --db path/to/patchdb --key oldfile --reason "Obsolete"

List patches in the audit log

python cli.py list-patches

Export audit log to HTML

python cli.py export-audit-html --output audit.html

✅ Running Tests

pytest tests/

🪑 Linting & Formatting

flake8
black patchlib.py cli.py tests/
isort patchlib.py cli.py tests/

📝 Notes

  • The default audit log is located at audit/patch_log.jsonl.
  • remove-patch automatically detects whether the content is text or binary.
  • This tool is meant to manage content patches, not full database snapshots.
  • For serving content from patched databases, see serve.py.

👷 Optional Improvements

If you're using this tool in production:

  • Consider setting up a Makefile
  • Enable pre-commit hooks for linting
  • Auto-export audits during CI/CD

About

A module that creates a patched levelDB instance that can be served simulataneous with the original levelDB

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages