ungoogled-software/ungoogled-chromium · error · FileExistsError
FileExistsError
Error message
FileExistsError
What it means
apply_substitution() raises FileExistsError(domainsub_cache) when a cache archive path is supplied and a file already exists at that location, to avoid overwriting an existing domain-substitution cache tar.
Source
Thrown at utils/domain_substitution.py:205
regex_path is a pathlib.Path to domain_regex.list
files_path is a pathlib.Path to domain_substitution.list
source_tree is a pathlib.Path to the source tree.
domainsub_cache is a pathlib.Path to the domain substitution cache.
Raises NotADirectoryError if the patches directory is not a directory or does not exist
Raises FileNotFoundError if the source tree or required directory does not exist.
Raises FileExistsError if the domain substitution cache already exists.
Raises ValueError if an entry in the domain substitution list contains the file index
hash delimiter.
"""
if not source_tree.exists():
raise FileNotFoundError(source_tree)
if not regex_path.exists():
raise FileNotFoundError(regex_path)
if not files_path.exists():
raise FileNotFoundError(files_path)
if domainsub_cache and domainsub_cache.exists():
raise FileExistsError(domainsub_cache)
resolved_tree = source_tree.resolve()
regex_pairs = DomainRegexList(regex_path).regex_pairs
fileindex_content = io.BytesIO()
with tarfile.open(str(domainsub_cache), f'w:{domainsub_cache.suffix[1:]}',
compresslevel=1) if domainsub_cache else open(
os.devnull, 'w', encoding=ENCODING) as cache_tar:
for relative_path in filter(len, files_path.read_text().splitlines()):
if _INDEX_HASH_DELIMITER in relative_path:
if domainsub_cache:
# Cache tar will be incomplete; remove it for convenience
cache_tar.close()
domainsub_cache.unlink()
raise ValueError(f'Path "{relative_path}" contains '
f'the file index hash delimiter "{_INDEX_HASH_DELIMITER}"')
path = resolved_tree / relative_path
if not path.exists():
get_logger().warning('Skipping non-existent path: %s', path)
continueView on GitHub (pinned to f85e84a480)
Solutions
- Delete the existing cache file before re-running apply_substitution()
- Pass a new/unique cache path (or domainsub_cache=None to skip caching)
- Only pass domainsub_cache when starting a fresh substitution
Example fix
// before
cache = Path('domsub_cache.tar.gz')
apply_substitution(tree, regexes, files, domainsub_cache=cache)
// after
cache = Path('domsub_cache.tar.gz')
if cache.exists():
cache.unlink()
apply_substitution(tree, regexes, files, domainsub_cache=cache) Defensive patterns
Strategy: validation
Validate before calling
cache = Path('domsub_cache.tar.gz').resolve()
if cache.exists():
cache.unlink() # or choose a new unique name Try / catch
try:
apply_substitution(tree, regexes, files, domainsub_cache=cache)
except FileExistsError:
cache.unlink()
apply_substitution(tree, regexes, files, domainsub_cache=cache) Prevention
- Clean stale cache files at the start of a substitution run
- Use unique cache names per source tree/run
- Only pass domainsub_cache for fresh runs
When it happens
Trigger: Calling apply_substitution() with a non-None domainsub_cache whose path .exists() — e.g. re-running apply after a previous run created the cache, or a stale cache file left behind.
Common situations: Re-running substitution after an aborted/previous run; resuming a pipeline where the cache wasn't cleaned; reusing the same cache filename for multiple source trees.
Related errors
- FileNotFoundError
- Could not find relative_to directory in extracted files: %s
- Temporary unpacking directory already exists: %s
- Unable to decode with any encoding: {path}
- Path "{relative_path}" contains the file index hash delimite
AI-assisted analysis of ungoogled-software/ungoogled-chromium@f85e84a480 (2026-08-29).
Data as JSON: /api/errors/ebc67b9e62b6ac20.
Report an issue: GitHub.