40 lines
1.9 KiB
Python
40 lines
1.9 KiB
Python
import datetime
|
|
import hashlib
|
|
import json
|
|
import pathlib
|
|
import shutil
|
|
|
|
root = pathlib.Path('C:/git/MagnetismHeroes').resolve()
|
|
final = root / 'artifacts/verification/Final'
|
|
visual = root / 'artifacts/verification/VisualUpgrade'
|
|
previous = visual / 'PreviousFinal'
|
|
failed = visual / 'FinalProduct/FailedAndroidAttempt1'
|
|
failed.mkdir(parents=True, exist_ok=True)
|
|
start = datetime.datetime.fromisoformat('2026-10-08T15:24:08+00:00').timestamp()
|
|
sha = lambda path: hashlib.sha256(path.read_bytes()).hexdigest()
|
|
copied = []
|
|
for path in final.rglob('*'):
|
|
if path.is_file() and path.stat().st_mtime >= start:
|
|
target = failed / 'Final' / path.relative_to(final)
|
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
shutil.copy2(path, target)
|
|
assert sha(path) == sha(target)
|
|
copied.append({'source': str(path.relative_to(root)), 'copy': str(target.relative_to(failed)), 'sha256': sha(target)})
|
|
for name in ['completion.json', 'androidsmoke-outer.log']:
|
|
path = visual / 'FinalProduct' / name
|
|
target = failed / name
|
|
shutil.copy2(path, target)
|
|
assert sha(path) == sha(target)
|
|
removed = []
|
|
old = json.loads((previous / 'manifest.json').read_text(encoding='utf-8'))
|
|
for entry in old['files']:
|
|
path = (root / entry['source']).resolve()
|
|
if path.is_relative_to(final.resolve()) and path.is_file() and path.stat().st_mtime < start:
|
|
backup = previous / entry['copy']
|
|
assert sha(path) == entry['sha256'] == sha(backup), path
|
|
removed.append({'source': entry['source'], 'sha256': entry['sha256'], 'preservedCopy': entry['copy']})
|
|
path.unlink()
|
|
record = {'status': 'PASS', 'failedAttemptPreserved': copied, 'stalePreviousFinalFilesRemovedAfterExactBackupProof': removed}
|
|
(failed / 'preservation-and-pruning.json').write_text(json.dumps(record, indent=2) + '\n', encoding='utf-8')
|
|
print(json.dumps({'status': 'PASS', 'failedAttemptFilesPreserved': len(copied), 'backedUpStaleFilesPruned': len(removed)}))
|