File Operations
Sietch's file operations are built around a sophisticated chunking and encryption system. Every file you add is automatically chunked, encrypted, and stored with deduplication support. Understanding these operations is crucial for effective vault management.
How Sietch Handles Files
The Chunking Process
When you add a file to Sietch:
- Chunking: The file is divided into chunks (default 4MB) using your vault's chunking strategy
- Hashing: Each chunk gets a content hash for deduplication and integrity verification
- Encryption: Chunks are encrypted using your vault's encryption settings
- Storage: Encrypted chunks are stored in
.sietch/chunks/
with cryptographic names - Manifest: A YAML manifest tracks file metadata, chunk references, and tags
Vault Structure
your-vault/
├── .sietch/
│ ├── chunks/ # Encrypted chunk storage
│ ├── manifests/ # File metadata and chunk references
│ ├── keys/ # Encryption keys
│ └── sync/ # Sync-related keys
└── vault.yaml # Vault configuration
Adding Files: sietch add
Add individual files to your vault with optional organization and tagging.
Usage
sietch add <source_path> <destination_path> [flags]
Options
Option | Type | Description |
---|---|---|
--force | flag | Force add without confirmation |
--tags | string | Comma-separated tags for organization |
--passphrase-value | string | Passphrase for encrypted vaults |
Key Behaviors
- Individual files only: Sietch add works with single files, not directories
- Automatic encryption: Files are immediately chunked and encrypted
- Deduplication: Identical content chunks are automatically deduplicated
- Path organization: Destination paths create logical organization within the vault
Examples
# Add a file to vault root
sietch add document.txt documents/
# Add with organizational path
sietch add research-data.csv research/datasets/
What Happens During Add
When you run sietch add document.txt documents/
:
- File Analysis: Sietch reads the file and calculates its size and modification time
- Chunking: The file is divided according to your chunking strategy
- Content Hashing: Each chunk receives a SHA256 (or Blake3) hash
- Deduplication Check: Sietch checks if identical chunks already exist
- Encryption: New chunks are encrypted with your vault's encryption key
- Storage: Encrypted chunks are stored with cryptographic filenames
- Manifest Creation: A YAML manifest records file metadata and chunk references
Example output:
File Metadata:
File: document.txt
Source: document.txt
Size: 1.2 KB (1,234 bytes)
Modified: 2025-09-23T10:30:15+00:00
Destination: documents/
Beginning chunking process...
Chunk 1: 1.2 KB bytes, hash: a1b2c3d4 (encrypted)
Total chunks processed: 1
Total bytes processed: 1.2 KB
✓ File added to vault: document.txt
✓ 1 chunks stored in vault
✓ Manifest written to .sietch/manifests/document.txt.yaml
Retrieving Files: sietch get
Extract and decrypt files from your vault back to the filesystem.
Usage
sietch get <file_path> <destination_path> [flags]
Options
Option | Type | Description |
---|---|---|
--force | flag | Force overwrite existing files |
--skip-decryption | flag | Retrieve raw chunks (for recovery) |
Important Notes
Base64 Encoding Behavior
Examples
# Get a file to current directory
sietch get documents/report.pdf ./
# Get file with specific name
sietch get vault/data.csv ~/Downloads/financial-data.csv
What Happens During Get
When you retrieve a file:
- Manifest Reading: Sietch reads the file's manifest to get chunk information
- Chunk Assembly: All chunks are located and read from storage
- Decryption: Each chunk is decrypted using your vault keys
- Reassembly: Chunks are reassembled in correct order
- Base64 Encoding: Content is encoded for safe output
- File Creation: The encoded file is written to destination
Example output:
Retrieving documents/report.pdf from vault
Reassembling file from 3 chunks
Processing chunk 1/3
Processing chunk 2/3
Processing chunk 3/3
File retrieved successfully: ./report.pdf
Size: 2.1 MB
Tags: [important, quarterly]
File successfully decrypted
Listing Files: sietch ls
View and organize files in your vault with powerful sorting and filtering options.
Usage
sietch ls [path] [flags]
Options
Option | Type | Default | Description |
---|---|---|---|
--long | flag | - | Detailed format with size, date, chunks |
--tags | flag | - | Display file tags |
--sort | string | path | Sort by: name , size , time , path |
Display Formats
# Basic file listing
sietch ls
# Output:
# documents/report.pdf
# research/data.csv
# vault/secrets.txt
Sorting and Filtering
# Sort by file size (largest first)
sietch ls --sort=size
# Sort by modification time (newest first)
sietch ls --sort=time
# Sort alphabetically by name
sietch ls --sort=name
Understanding the Output
The long format provides crucial information:
- SIZE: File size (original, before chunking/encryption)
- MODIFIED: Last modification time from original file
- CHUNKS: Number of chunks the file is split into
- PATH: Virtual path within the vault
- TAGS: User-defined tags for organization
Deleting Files: sietch delete
Remove files from your vault with automatic chunk cleanup.
Usage
sietch delete <file_path> [flags]
Options
Option | Type | Description |
---|---|---|
--force | flag | Skip confirmation prompt |
--keep-chunks | flag | Delete manifest but preserve chunks |
Deletion Process
- Confirmation Required: By default, Sietch asks for confirmation
- Manifest Removal: The file's manifest is deleted immediately
- Chunk Cleanup: Orphaned chunks are automatically removed
- Deduplication Aware: Shared chunks used by other files are preserved
Examples
# Delete with confirmation
sietch delete documents/report.pdf
# Prompt: Are you sure you want to delete 'documents/report.pdf'? (y/N):
# Force delete without confirmation
sietch delete old-files/backup.zip --force
What Happens During Delete
- Confirmation: User confirms deletion (unless
--force
used) - Manifest Removal: File manifest is deleted from
.sietch/manifests/
- Chunk Analysis: Sietch identifies which chunks were used by the file
- Reference Check: Checks if chunks are used by other files
- Cleanup: Removes orphaned chunks not referenced elsewhere
- Deduplication Update: Updates deduplication indices
Example output:
Warning: Failed to delete chunk a1b2c3d4...: chunk still referenced by other files
✓ Successfully deleted 'documents/report.pdf' from vault
✓ Cleaned up 2 orphaned chunks
✓ Freed 1.8 MB of storage space
Advanced File Management
Understanding Manifests
Each file in your vault has a YAML manifest that stores metadata:
file: research.txt
size: 52
mtime: "2025-09-23T13:05:35+05:30"
chunks:
- hash: 9fa35c8f680d121b...
encrypted_hash: 06a4261c9d152baed...
size: 52
encrypted_size: 200
index: 0
destination: research/
tags:
- important
- survival
added_at: 2025-09-23T07:35:50.635546248Z
Deduplication in Action
Sietch automatically deduplicates identical content:
# Add two files with identical content
echo "Same content" > file1.txt
echo "Same content" > file2.txt
sietch add file1.txt test/
sietch add file2.txt test/
# Check deduplication statistics
sietch dedup stats
File Tags and Organization
Tags provide powerful organization capabilities:
# Organizational tags
sietch add report.pdf reports/ --tags "quarterly,finance,2024"
# Priority tags
sietch add urgent-memo.txt alerts/ --tags "urgent,action-required"
# Project tags
sietch add research-data.csv projects/ --tags "project-alpha,research,confidential"
Best Practices
File Organization
- Use descriptive paths:
documents/contracts/2024/
instead ofdocs/
- Tag consistently: Develop a tagging strategy for your use case
- Group related files: Keep project files in dedicated paths
- Regular cleanup: Use
sietch delete
to remove outdated files
Security Considerations
Sensitive File Handling
Performance Optimization
- Chunk size matters: Larger chunks for big files, smaller for deduplication
- Monitor deduplication: Use
sietch dedup stats
to track efficiency - Regular garbage collection: Run
sietch dedup gc
to clean orphaned chunks - Tag organization: Use consistent tagging for easier file management
Troubleshooting
Common Issues
File won't add: Ensure the source file exists and you have read permissions.
Can't retrieve file: Check that the file path exists in the vault with sietch ls
.
Base64 output: Remember to decode retrieved files with base64 -d
.
Deletion warnings: Warnings about chunk cleanup are normal and indicate successful deduplication.
Recovery Scenarios
# Retrieve raw chunks for manual recovery
sietch get corrupted-file.dat ./recovery/ --skip-decryption
# Check chunk integrity
sietch dedup stats
Learn how to synchronize your vault with peers and manage distributed storage across multiple devices.