Add hash conflict detection and cleanup across chains in import operations and improve database initialization
Some checks failed
Some checks failed
- Add hash conflict detection in import_block to delete existing blocks with same hash - Add hash conflict cleanup in import_chain before importing blocks - Add logging for hash conflict deletions showing affected chains - Add WAL file permission setting in init_db for .db-shm and .db-wal files - Add test_import_chain_clears_hash_conflicts_across_chains to verify cross-chain hash cleanup
This commit is contained in:
@@ -86,9 +86,16 @@ def init_db() -> None:
|
||||
# If tables already exist, that's okay
|
||||
if "already exists" not in str(e):
|
||||
raise
|
||||
# Set restrictive file permissions on database file
|
||||
# Set restrictive file permissions on database file and WAL files
|
||||
if settings.db_path.exists():
|
||||
os.chmod(settings.db_path, stat.S_IRUSR | stat.S_IWUSR) # Read/write for owner only
|
||||
# Also set permissions on WAL files if they exist
|
||||
wal_shm = settings.db_path.with_suffix('.db-shm')
|
||||
wal_wal = settings.db_path.with_suffix('.db-wal')
|
||||
if wal_shm.exists():
|
||||
os.chmod(wal_shm, stat.S_IRUSR | stat.S_IWUSR)
|
||||
if wal_wal.exists():
|
||||
os.chmod(wal_wal, stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
# Restricted engine access - only for internal use
|
||||
def get_engine():
|
||||
|
||||
Reference in New Issue
Block a user