import { i18n } from '../i18n' import { sdk } from '../sdk' import { dataDir, INDEXER_DIR } from '../utils' export const resetIndexerState = sdk.Action.withoutInput( // id 'reset-indexer-state', // metadata async ({ effects }) => ({ name: i18n('Reset Indexer State'), description: i18n( 'Wipe /data/explorer-indexer so the next start re-fetches the indexer source and rebuilds the sync + goose binaries.', ), warning: i18n( 'This deletes the cached indexer source and compiled binaries. The next start will need internet access to re-download from GitHub and to fetch Go modules. PostgreSQL data (the indexed blocks themselves) is preserved — use Reset Database State if you also want to clear that.', ), allowedStatuses: 'any', group: null, visibility: 'enabled', }), // run async ({ effects }) => { const res = await sdk.SubContainer.withTemp( effects, { imageId: 'spaces' }, sdk.Mounts.of().mountVolume({ volumeId: 'main', subpath: null, mountpoint: dataDir, readonly: false, }), 'spaces-reset-indexer', (subc) => subc.exec(['rm', '-rf', INDEXER_DIR], { user: 'root' }), ) if (res.exitCode !== 0) { return { version: '1', title: i18n('Failure'), message: i18n('Could not wipe indexer state: ${error}', { error: (res.stderr ?? '').toString() || `exit ${res.exitCode}`, }), result: null, } } return { version: '1', title: i18n('Success'), message: i18n( 'Indexer cache has been wiped. Start (or restart) the service to re-fetch and rebuild from GitHub.', ), result: null, } }, )