Skip to content

Commit

Permalink
Only warn of broken LFN chains, do not fail when encountering one
Browse files Browse the repository at this point in the history
Some drivers might under some circumstances (e.g., not LFN aware)
leave broken LFN chains in a directory listing. To avoid having
unreadable filesystems due to strict handling it is more advisable
to instead just warn the user and just discard the broken LFN
entry altogether.
  • Loading branch information
nathanhi committed Apr 10, 2022
1 parent 54640fb commit 96ae6bc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyfatfs/FATDirectoryEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Directory entry operations with PyFAT."""
import posixpath
import struct
import warnings

from time import timezone

Expand Down Expand Up @@ -94,7 +95,11 @@ def __init__(self, DIR_Name: EightDotThree, DIR_Attr: int,

# Handle LFN entries
self.lfn_entry = None
self.set_lfn_entry(lfn_entry)
try:
self.set_lfn_entry(lfn_entry)
except BrokenLFNEntryException:
warnings.warn("Broken LFN entry detected, omitting "
"long file name.")

self.__dirs = []
self.__encoding = encoding
Expand Down

0 comments on commit 96ae6bc

Please sign in to comment.