๐Ÿ” stewbeet.plugins.compute_sha1

๐Ÿ“„ Source Code: stewbeet/plugins/compute_sha1/__init__.py ๐Ÿ”—

๐Ÿ“‹ Overview

The compute_sha1 plugin generates SHA1 hashes for all generated zip archives.
It scans the output directory for zip files, computes their SHA1 checksums for integrity
verification, and creates a comprehensive JSON file containing all hash values
for distribution verification, security auditing, and change detection purposes.

Feature Showcase

Example content of sha1_hashes.json

๐ŸŽฏ Purpose

  • ๐Ÿ” Computes SHA1 hashes for all generated zip archives
  • ๐Ÿ“‹ Creates comprehensive hash manifest for integrity verification
  • ๐Ÿ” Enables change detection between builds
  • ๐Ÿ›ก๏ธ Provides security checksums for distribution verification
  • ๐Ÿ“ Scans output directory automatically for zip files
  • ๐Ÿ’พ Generates machine-readable JSON hash file

๐Ÿ”— Dependencies

  • ๐Ÿ“ Position: Should run after all archive generation plugins
  • ๐Ÿ”ง Optional: Multiple zip files in output directory (processes all found)
  • ๐Ÿ“‹ Related: Complements archive and merge_smithed_weld plugins

โš™๏ธ Configuration

๐ŸŽฏ Basic Example Configuration

# No direct configuration required - uses project settings # Requires output to be configured in beet.yml: output: "build" pipeline: - ... - stewbeet.plugins.compute_sha1

๐Ÿ“‹ Configuration Options

OptionTypeDefaultDescription
outputstringRequiredDirectory containing zip files to hash
Hash AlgorithmconstantSHA1Uses SHA1 algorithm for checksum generation
Output Fileconstantsha1_hashes.jsonFilename for the generated hash manifest
File Filterautomatic*.zipOnly processes files with .zip extension

โœจ Features

๐Ÿ” Automatic Archive Discovery

Scans output directory for zip files to process:

  • ๐Ÿ“ Automatically discovers all zip files in the output directory
  • ๐Ÿ” Uses file extension filtering to identify archive files
  • ๐Ÿ“‹ Processes all found archives without manual configuration
  • โœ… Handles empty directories gracefully with no errors

๐Ÿ” SHA1 Hash Computation

Generates secure SHA1 checksums for each archive:

  • ๐Ÿ” Uses Python's built-in hashlib for reliable hash generation
  • ๐Ÿ“– Reads files in binary mode for accurate checksum calculation
  • ๐ŸŽฏ Generates standard hexadecimal hash representation
  • โšก Processes files efficiently with stream reading

๐Ÿ“‹ Hash Manifest Creation

Creates comprehensive JSON file with all computed hashes:

  • ๐Ÿ“ Stores filename-to-hash mappings in JSON format
  • ๐ŸŽจ Uses json_dump for properly formatted output
  • ๐Ÿ’พ Creates sha1_hashes.json file in the output directory
  • ๐Ÿ“Š Provides machine-readable format for automated verification

๐Ÿ›ก๏ธ Integrity Verification System

Enables integrity checking and change detection:

  • โœ… Provides checksums for verifying archive integrity
  • ๐Ÿ” Enables detection of file corruption or tampering
  • ๐Ÿ“Š Supports automated verification workflows
  • ๐Ÿ”’ Creates audit trail for security compliance

๐Ÿ“ Output Directory Integration

Seamlessly integrates with beet's output directory system:

  • ๐Ÿ“‚ Uses configured output directory from project settings
  • โœ… Validates output directory existence before processing
  • ๐ŸŽฏ Works with any output directory configuration
  • ๐Ÿ”ง Integrates with beet's standard directory management

โšก Efficient Processing Pipeline

Optimized for performance with minimal resource usage:

  • โฑ๏ธ Uses measure_time decorator for performance monitoring
  • ๐Ÿ’พ Reads files once for hash calculation
  • ๐Ÿ“Š Processes all files in a single pass
  • ๐Ÿงน Clean and simple implementation with minimal overhead