Skip to content

Commit 9de93db

Browse files
committed
Fixing Sentry.io OPENSHOT-5KAW: Failed to load media file into video player. Stopped using log.error for this, and added more checks for if files exist before previewing and thumbnailing them.
1 parent d727e45 commit 9de93db

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/classes/thumbnail.py

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def GetThumbPath(file_id, thumbnail_frame, clear_cache=False):
7474

7575
def GenerateThumbnail(file_path, thumb_path, thumbnail_frame, width, height, mask, overlay):
7676
"""Create thumbnail image, and check for rotate metadata (if any)"""
77+
if not os.path.exists(file_path):
78+
log.warning(f"Cannot generate thumbnail for missing file: {file_path}")
79+
return
7780

7881
# Create a clip object and get the reader
7982
clip = openshot.Clip(file_path)

src/windows/preview_thread.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import time
2929
import sip
3030
import math
31+
import os
3132

3233
from PyQt5.QtCore import QObject, QThread, QTimer, pyqtSlot, pyqtSignal, QCoreApplication
3334
from PyQt5.QtWidgets import QMessageBox
@@ -309,7 +310,8 @@ def LoadFile(self, path=None):
309310
""" Load a media file into the video player """
310311
# Check to see if this path is already loaded
311312
# TODO: Determine why path is passed in as an empty string instead of None
312-
if path == self.clip_path or (not path and not self.clip_path):
313+
if path == self.clip_path or (not path and not self.clip_path) or not os.path.exists(path):
314+
log.warning(f"Cannot load missing file for preview: {path}")
313315
return
314316

315317
log.info("LoadFile %s" % path)
@@ -361,8 +363,7 @@ def LoadFile(self, path=None):
361363
new_clip = openshot.Clip(path)
362364
self.clip_reader.AddClip(new_clip)
363365
except:
364-
log.error('Failed to load media file into video player: %s' % path)
365-
return
366+
log.warning('Failed to load media file into video player: %s' % path)
366367

367368
# Assign new clip_reader
368369
self.clip_path = path

0 commit comments

Comments
 (0)