Skip to content

Commit

Permalink
Add exception handling for os.path.getmtime
Browse files Browse the repository at this point in the history
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
  • Loading branch information
LorenEteval committed May 28, 2024
1 parent f88b706 commit 9589f16
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Furious/Widget/XrayAssetViewerQListWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,17 @@ def flushItemByTheme(self, theme: str):

for filename in os.listdir(XRAY_ASSET_DIR):
if os.path.isfile(XRAY_ASSET_DIR / filename):
epoch = os.path.getmtime(XRAY_ASSET_DIR / filename)
mdate = datetime.datetime.fromtimestamp(epoch).strftime(
'%Y-%m-%d %H:%M:%S'
)
try:
# Exception may be raised
epoch = os.path.getmtime(XRAY_ASSET_DIR / filename)
except Exception:
# Any non-exit exceptions

mdate = ''
else:
mdate = datetime.datetime.fromtimestamp(epoch).strftime(
'%Y-%m-%d %H:%M:%S'
)

item = QListWidgetItem(f'{filename:{maxlen + 6}}{mdate}')
item.setFont(QFont(APP().customFontName))
Expand Down

0 comments on commit 9589f16

Please sign in to comment.