#!/usr/bin/env python3 import hashlib import json import pathlib import sys import bpy TEXT_NAME = "WBV2-P1-005-StorageJournalContract" CONTRACT_ID = "workflow:harden_opfs_indexeddb_journal_recovery" def contract(): value = { "schemaVersion": 1, "contractId": CONTRACT_ID, "journal": { "interruptedAt": "BEFORE_PUBLISH", "oldProjectUsable": True, "recovery": "ROLLBACK_OLD_REVISION", "stagedRevision": 8, "oldRevision": 7, }, "hash": { "expected": "sha256:project-revision-8", "mismatch": "QUARANTINED", "verified": False, }, "storage": { "indexeddb": {"afterRecovery": 0, "journalEntriesBefore": 1, "metadataRevision": 7}, "opfs": {"afterRecovery": 0, "stagingFilesBefore": 1, "projectReadable": True}, }, "restart": {"generationAfter": 2, "generationBefore": 1, "status": "RECOVERED"}, "budget": {"maxJournalEntries": 32, "maxProjectBytes": 4 * 1024 * 1024}, "extensions": {"futureField": {"kind": "opaque", "value": "preserve-me"}}, } encoded = json.dumps(value, sort_keys=True, separators=(",", ":")) value["schemaHash"] = hashlib.sha256(encoded.encode("utf-8")).hexdigest() return value def main(output): bpy.ops.wm.read_factory_settings(use_empty=True) mesh = bpy.data.meshes.new("WBV2P1005StorageMesh") mesh.from_pydata( [(-1, -1, -1), (1, -1, -1), (1, 1, -1), (-1, 1, -1), (-1, -1, 1), (1, -1, 1), (1, 1, 1), (-1, 1, 1)], [], [(0, 1, 2, 3), (4, 7, 6, 5), (0, 4, 5, 1), (1, 5, 6, 2), (2, 6, 7, 3), (4, 0, 3, 7)], ) mesh.update() obj = bpy.data.objects.new("WBV2P1005StorageObject", mesh) bpy.context.collection.objects.link(obj) text = bpy.data.texts.new(TEXT_NAME) text.write(json.dumps(contract(), sort_keys=True, separators=(",", ":"))) text.use_fake_user = True bpy.ops.wm.save_as_mainfile(filepath=str(output.resolve()), check_existing=False, compress=True) if __name__ == "__main__": arguments = sys.argv[sys.argv.index("--") + 1 :] if len(arguments) != 1: raise SystemExit("usage: blender -b --factory-startup --python WBV2-P1-005.py -- OUTPUT") main(pathlib.Path(arguments[0]))