|
|
|
""" |
|
Script to reconstruct original files from split parts. |
|
Run this after downloading the model to reconstruct large files. |
|
""" |
|
|
|
import json |
|
import os |
|
from pathlib import Path |
|
|
|
def reconstruct_files(): |
|
"""Reconstruct original files from parts using the manifest.""" |
|
with open("split_manifest.json", 'r') as f: |
|
manifest = json.load(f) |
|
|
|
for original_file, info in manifest.items(): |
|
print(f"Reconstructing {original_file}...") |
|
|
|
output_path = Path(original_file) |
|
output_path.parent.mkdir(parents=True, exist_ok=True) |
|
|
|
with open(output_path, 'wb') as output_file: |
|
for part_file in info["parts"]: |
|
with open(part_file, 'rb') as part: |
|
output_file.write(part.read()) |
|
|
|
|
|
if output_path.stat().st_size == info["original_size"]: |
|
print(f" ✓ Reconstructed successfully ({output_path.stat().st_size} bytes)") |
|
|
|
|
|
for part_file in info["parts"]: |
|
os.remove(part_file) |
|
print(f" Removed part: {part_file}") |
|
else: |
|
print(f" ✗ Size mismatch for {original_file}") |
|
|
|
|
|
os.remove("split_manifest.json") |
|
print("Reconstruction complete!") |
|
|
|
if __name__ == "__main__": |
|
reconstruct_files() |
|
|