Skip to content

Conversation

@twilight39
Copy link
Contributor

Description

The Python os.stat() function below throws an unhandled OSError exception if the file being read's path length exceeds what the OS allows (e.g. 255 on Win7, 1024 on Mac).

vorta/src/vorta/utils.py

Lines 116 to 125 in 0a316e7

try:
stat = os.stat(file_path)
if stat.st_ino not in seen: # Visit each file only once
# this won't add the size of a hardlinked file
seen.add(stat.st_ino)
if not is_excluded:
data_size_filtered += stat.st_size
seen_filtered.add(stat.st_ino)
except (FileNotFoundError, PermissionError):
continue

Related Issue

fixes #2115

Motivation and Context

Currently, the whole application will crash when estimating backup size if a single file (even if it's excluded) exceeds the maximum length allowed by the OS. PR #2206 addresses excluding files from being calculated as part of the backup size, and this PR ignores files that have an excessive path length.

How Has This Been Tested?

I've run the pytest and pre-commit tests and they have passed.
I'm unable to manually test this as MacOS will not allow me to create a file with a path length exceeding 1024.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.

@m3nu
Copy link
Contributor

m3nu commented Mar 15, 2025

Good job. A very precise fix!

@m3nu m3nu merged commit 0879ae0 into borgbase:master Mar 15, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"File name too long" when calculating source size (exclusions not respected?)

2 participants