Files
Investidor-V2/outputs/investmoz-promotor-contexto-ativacao-20261015/revert.py
T
nala 6a76aac80f
tests / ci (push) Canceled after 0s
versao compilada 1
2026-10-16 09:17:28 +02:00

27 lines
1.7 KiB
Python

from pathlib import Path
import hashlib,json,subprocess,os,shutil,sys
root=Path(__file__).resolve().parents[2];out=Path(__file__).resolve().parent
assert sys.argv[1:]==['--revert=promotor-contexto-QA-e8858cb44dca'],'Exact reversal argument required'
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
m=json.loads((root/'outputs/investmoz-promotor-contexto-QA-20261015/MANIFESTO-DELTA.json').read_text('utf-8'))
b=json.loads((out/'FRESH-BACKUP.json').read_text('utf-8'));backup=Path(b['private_directory'])
assert b['restore_verified'] and b['files_verified'] and b['candidate']==m['candidate']
for s in m['sources']:
assert sha(root/s['path'])==s['candidate_sha256'],'Concurrent change: '+s['path']
if s['previous_sha256'] is not None:assert sha(backup/'files'/s['path'])==s['previous_sha256']
assert not (root/'storage/framework/down').exists()
php='C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64/php.exe'
def artisan(*args):
p=subprocess.run([php,'artisan',*args],cwd=root,capture_output=True)
assert p.returncode==0,'Reversal command failed; retain maintenance and inspect private logs'
artisan('down','--retry=60')
for s in m['sources']:
if s['previous_sha256'] is None:continue
dest=root/s['path'];tmp=dest.with_name(dest.name+'.promoter-reversal.tmp');assert not tmp.exists()
shutil.copy2(backup/'files'/s['path'],tmp);os.replace(tmp,dest);assert sha(dest)==s['previous_sha256']
for s in m['sources']:
if s['previous_sha256'] is None:
dest=root/s['path'];assert sha(dest)==s['candidate_sha256'];dest.unlink()
artisan('view:clear');artisan('up')
print('Two PHP originals restored; new view removed; business data and classification contract preserved.')