Skip to main content

Rust-powered filesystem toolkit: fast walk, parallel hashing, bulk copy, file watching, and deduplication.

Project description

fs_watcher

Rust-powered filesystem toolkit for Python. Fast recursive directory listing, parallel file hashing, bulk copy/move with progress, cross-platform file watching, and file deduplication.

Install

pip install pyfs_watcher

From source:

pip install maturin
maturin develop

Usage

Walk directories (parallel, faster than os.walk)

import fs_watcher

# Streaming iterator
for entry in fs_watcher.walk("/data", file_type="file", glob_pattern="*.py"):
    print(entry.path, entry.file_size)

# Bulk collect (faster when you need all results)
entries = fs_watcher.walk_collect("/data", max_depth=3, sort=True, skip_hidden=True)

Hash files (parallel SHA256/BLAKE3)

# Single file
result = fs_watcher.hash_file("large.iso", algorithm="blake3")
print(result.hash_hex)

# Parallel batch hashing
results = fs_watcher.hash_files(paths, algorithm="blake3", callback=lambda r: print(r.path))

Copy/move with progress

def on_progress(p):
    pct = p.bytes_copied / p.total_bytes * 100
    print(f"{pct:.0f}% - {p.current_file}")

fs_watcher.copy_files(sources, "/dest", progress_callback=on_progress)
fs_watcher.move_files(sources, "/dest")  # rename if same fs, copy+delete otherwise

Watch for file changes

# Sync
with fs_watcher.FileWatcher("/data", debounce_ms=500, ignore_patterns=["*.tmp"]) as w:
    for changes in w:
        for c in changes:
            print(c.path, c.change_type)  # "created", "modified", "deleted"

# Async
async for changes in fs_watcher.async_watch("/data"):
    for c in changes:
        print(c.path, c.change_type)

Find duplicate files

groups = fs_watcher.find_duplicates(
    ["/photos", "/backup"],
    min_size=1024,
    progress_callback=lambda stage, done, total: print(f"{stage}: {done}/{total}"),
)
for g in groups:
    print(f"{g.file_size}B x {len(g.paths)} copies = {g.wasted_bytes}B wasted")
    for path in g.paths:
        print(f"  {path}")

API

All functions raise typed exceptions inheriting from FsWatcherError:

  • WalkError - directory walk failures
  • HashError - hashing failures
  • CopyError - copy/move failures
  • WatchError - file watching failures

Standard FileNotFoundError and PermissionError are raised for I/O errors.

Development

# Setup
uv venv && source .venv/bin/activate
uv pip install maturin pytest pytest-asyncio pytest-timeout

# Build
maturin develop

# Test
cargo test        # Rust tests
pytest tests/     # Python tests

# Benchmark
python benches/bench_walk.py
python benches/bench_hash.py

Tech

  • Rust + PyO3 for Python bindings
  • jwalk for parallel directory traversal
  • BLAKE3/SHA-256 for hashing with rayon parallelism
  • notify + debouncer for cross-platform file watching
  • Staged dedup pipeline: size grouping -> partial hash -> full hash

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

pyfs_watcher-0.1.0.tar.gz (34.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyfs_watcher-0.1.0-cp39-abi3-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.9+Windows x86-64

pyfs_watcher-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

pyfs_watcher-0.1.0-cp39-abi3-macosx_11_0_arm64.whl (875.3 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file pyfs_watcher-0.1.0.tar.gz.

File metadata

  • Download URL: pyfs_watcher-0.1.0.tar.gz
  • Upload date:
  • Size: 34.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyfs_watcher-0.1.0.tar.gz
Algorithm Hash digest
SHA256 41bb39093332954ea592f98a062bf5ecbde4385a55abeb2f63881f2cd02e64b9
MD5 fc1333576ee70a8531c1e3c40bfb685d
BLAKE2b-256 72b6e90c8e8f337440066050cf10d6b0b61e56906d5da7967399ce7450750e43

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfs_watcher-0.1.0.tar.gz:

Publisher: publish.yml on pratyush618/pyfs-watcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfs_watcher-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: pyfs_watcher-0.1.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyfs_watcher-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 42b48c6431d3fc9e13512fdc761ea057e2e004c07d7539ce25c34084202fe08c
MD5 96aab2314f2eb07751e9bb757d3499c0
BLAKE2b-256 afa05d2ba3ae020ca334fd322f133dbb4e7a78b56820b3fe2f7aba451c1f11e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfs_watcher-0.1.0-cp39-abi3-win_amd64.whl:

Publisher: publish.yml on pratyush618/pyfs-watcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfs_watcher-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyfs_watcher-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 30c19e2f64ed567e71eb7ad28cd4ee284ed0edbe6c97c71454c73f992ba91e78
MD5 3da7a88ac66a2481372cd6fe39b88be2
BLAKE2b-256 e12816638881275d1ed967f01cb9c3ce9568eab3e674bbde641fdfcb8b216b8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfs_watcher-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on pratyush618/pyfs-watcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfs_watcher-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyfs_watcher-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ddb81a4c57c81d1c7a71f3abc3aeb45b074207b726c480d5c460b88ff02ce77
MD5 14d3ccc210fde87674ff197b6c06a41f
BLAKE2b-256 66f0fe3ba3bb05ed1f200d537aba01a81422ede3404e18157258d31eea269d4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfs_watcher-0.1.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on pratyush618/pyfs-watcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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