Skip to content

Sincronizar Sugestões — Design Técnico

Gerado pelo Writer (Reversa) em 2026-05-11

Fluxo Detalhado

dispatch(baixar)
  → new SugestoesRepertorioService()
  → baixarSugestoes()
      → downloadEmAndamento = true
      → Api.APP_BIBLIOTECA_SUGESTOES_REPERTORIO_SQLITE()
      → RNFetchBlob.download(url, cachePath('sugestoes_repertorio.db'))
      → BibliotecaSugestoesRepertorioRepository.importarSugestoes()
          → Banco.attachFromCache(path, 'sugestoesImport')
          → try:
              → DELETE FROM sugestao_repertorio WHERE 1=1
              → INSERT INTO sugestao_repertorio SELECT … FROM sugestoesImport.sugestao_repertorio
          → finally:
              → DETACH DATABASE sugestoesImport
      → downloadEmAndamento = false  ← no finally
  → dispatch(carregarLista())

Alias ATTACH

Alias Operação Finally
sugestoesImport importarSugestoes DETACH garantido

Comparação com BibliotecaRepository

Aspecto Sugestões Obras
Alias sugestoesImport toImport
Mutex downloadEmAndamento (estático) downloadEmAndamento (estático)
Estratégia import DELETE total + INSERT DELETE + INSERT por ID

Riscos e Lacunas

  • 🔴 Mutex é static boolean — falso negativo possível após crash (app reiniciado com downloadEmAndamento = false por padrão)
  • 🟡 Sem CRC32 antes de importar — download e import ocorrem mesmo se dados idênticos