Skip to content

Support non-empty directory as datadir #5680

Description

@ManuelBilbao

EthDocker puts the JWT among other stuff in the same directory as the datadir, causing an error as the code expect an empty dir (here:)

ethrex/crates/storage/store.rs

Lines 2849 to 2850 in 2f60e7e

// If datadir exists but is not empty, this is probably a DB for an
// old ethrex version and we should return an error

We should do a better check for old DB existance and allow non-empty dirs

Activity

  1. MegaRedHand commented on Dec 18, 2025

    @MegaRedHand
    Collaborator

    Alt: we could store the DB inside <datadir_path>/data. Would be cleaner and more difficult for users to trip on

  2. added
    good first issue
    on Jan 7, 2026
  3. added theissue type on Jan 7, 2026
  4. pjdurden commented on Jun 3, 2026

    @pjdurden
    Contributor

    I'd like to take this. The check at store.rs#L2849-L2850 treats any non-empty datadir as an error, but the real intent is "don't clobber an existing DB." Plan: instead of asserting the dir is empty, probe for the actual DB marker (libmdbx mdbx.dat / the rocksdb dir, per configured backend) and only refuse when a real prior DB exists — otherwise proceed so unrelated files (JWT, etc.) can coexist, which is what EthDocker needs. I'll add tests for (a) empty dir, (b) dir with only a JWT, (c) dir with an existing DB. Happy to align on the exact marker per backend before I open the PR.

  5. added a commit that references this issue on Jun 17, 2026
    7807924
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions