Fix handling of dangling symlink on manifest generation
There may be broken symlinks within the log directories, those fail with an error when os.stat() is executed on them. Let's just skip those. Change-Id: I3e6982c53a08f57ac0e592b8a0041bbb39812d1f
This commit is contained in:
parent
c74b03649a
commit
dd40f5ed9f
@ -67,14 +67,19 @@ def walk(root, original_root=None):
|
|||||||
mime_guess, encoding = mimetypes.guess_type(path)
|
mime_guess, encoding = mimetypes.guess_type(path)
|
||||||
if not mime_guess:
|
if not mime_guess:
|
||||||
mime_guess = 'text/plain'
|
mime_guess = 'text/plain'
|
||||||
st = os.stat(path)
|
# This may fail e.g. for dangling symlinks, just ignore those
|
||||||
last_modified = st[stat.ST_MTIME]
|
try:
|
||||||
size = st[stat.ST_SIZE]
|
st = os.stat(path)
|
||||||
data.append(dict(name=f,
|
last_modified = st[stat.ST_MTIME]
|
||||||
mimetype=mime_guess,
|
size = st[stat.ST_SIZE]
|
||||||
encoding=encoding,
|
data.append(dict(name=f,
|
||||||
last_modified=last_modified,
|
mimetype=mime_guess,
|
||||||
size=size))
|
encoding=encoding,
|
||||||
|
last_modified=last_modified,
|
||||||
|
size=size))
|
||||||
|
except FileNotFoundError:
|
||||||
|
continue
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user