Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Consiliency_treesitter-chunker /chunker /_internal /file_utils.py
| """File utilities for internal use.""" | |
| import hashlib | |
| from dataclasses import dataclass | |
| from pathlib import Path | |
| class FileMetadata: | |
| """Metadata about a file.""" | |
| path: Path | |
| size: int | |
| hash: str | |
| mtime: float | |
| def compute_file_hash(path: Path, chunk_size: int = 8192) -> str: | |
| """Compute SHA-256 hash of a file.""" | |
| sha256_hash = hashlib.sha256() | |
| with path.open("rb") as f: | |
| while chunk := f.read(chunk_size): | |
| sha256_hash.update(chunk) | |
| return sha256_hash.hexdigest() | |
| def get_file_metadata(path: Path) -> FileMetadata: | |
| """Get file metadata including size, hash, and modification time.""" | |
| stat = path.stat() | |
| return FileMetadata( | |
| path=path, | |
| size=stat.st_size, | |
| hash=compute_file_hash(path), | |
| mtime=stat.st_mtime, | |
| ) | |
Xet Storage Details
- Size:
- 828 Bytes
- Xet hash:
- a8c31e4939b7552e5f2eb47467abbf4e5dd0dd3af2d4e93a9649e911ee4d99eb
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.