@danhachuel/thunderbolt 0.6.79 → 0.6.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -457,7 +457,7 @@ class StorageIntegrityError(RuntimeError):
457
457
 
458
458
 
459
459
  @contextmanager
460
- def _state_lock(path: Path) -> Iterator[None]:
460
+ def _state_lock(path: Path, *, read_only: bool = False) -> Iterator[None]:
461
461
  """Serialise state mutations across the UI and both local workers.
462
462
 
463
463
  A lock file is used instead of an in-memory mutex because the launcher
@@ -472,6 +472,15 @@ def _state_lock(path: Path) -> Iterator[None]:
472
472
  try:
473
473
  descriptor = os.open(lock_path, os.O_CREAT | os.O_EXCL | os.O_WRONLY)
474
474
  os.write(descriptor, f"pid={os.getpid()}\n".encode("ascii"))
475
+ except PermissionError:
476
+ if not read_only:
477
+ raise
478
+ # Windows pode manter um lock residual aberto por outro processo
479
+ # (ou por antivírus). Leituras de JSON continuam seguras porque as
480
+ # escritas usam replace atómico; não bloquear a leitura evita que
481
+ # uma página inteira falhe por causa de um lock de metadados.
482
+ yield
483
+ return
475
484
  except FileExistsError:
476
485
  try:
477
486
  if time.time() - lock_path.stat().st_mtime > _LOCK_STALE_SECONDS:
@@ -557,7 +566,7 @@ def _recover_json_unlocked(name: str, path: Path, default: Any | None) -> Any:
557
566
  def read_json(name: str, default: Any | None = None) -> Any:
558
567
  ensure_storage()
559
568
  path = STATE / name
560
- with _state_lock(path):
569
+ with _state_lock(path, read_only=True):
561
570
  try:
562
571
  data = _load_json_unlocked(path)
563
572
  except (json.JSONDecodeError, OSError):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.6.79",
3
+ "version": "0.6.80",
4
4
  "description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
5
5
  "license": "MIT",
6
6
  "main": "scripts/cli.mjs",