Skip to content

Conversation

laanwj
Copy link
Member

@laanwj laanwj commented Apr 21, 2024

For long-running instances, leveldb file numbers can go on beyond 6 digits. Adapt the regexp to this.

For long-running instances, leveldb file numbers can go on beyond 6
digits. Adapt the regexp to this.
@tdb3
Copy link

tdb3 commented May 5, 2024

CR ACK for a29e014

This seems to work well for files with additional digits.

Just a minor nit. Technically, without escaping the period in the regex, files with a character other than period match. Not sure if we care to make this a more strict regex given its scope of use and the likely contents of the directory. If so, it would be a separate PR than this one.

>>> fnames = {'six_digit':'123456.ldb', 'seven_digit':'9123456.ldb', 'six_digit_not_period':'123456!ldb', 'seven_digit_not_period':'9123456!ldb', 'eight_digit':'89123456.ldb'}
>>> for f in fnames:
...     if re.match('^[0-9]{6}.ldb$', fnames[f]):
...         print(f, 'matched the regex')
...     else:
...         print(f, 'didn\'t match the regex')
... 
six_digit matched the regex
seven_digit didn't match the regex
six_digit_not_period matched the regex
seven_digit_not_period didn't match the regex
eight_digit didn't match the regex
>>> for f in fnames:
...     if re.match('^[0-9]{6,}.ldb$', fnames[f]):
...         print(f, 'matched the regex')
...     else:
...         print(f, 'didn\'t match the regex')
... 
six_digit matched the regex
seven_digit matched the regex
six_digit_not_period matched the regex
seven_digit_not_period matched the regex
eight_digit matched the regex

@fanquake fanquake merged commit f9b8456 into bitcoin-core:main May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants