From: Calin Crisan Date: Fri, 25 Dec 2015 19:50:34 +0000 (+0200) Subject: media browser file removal fix X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=50967378fcb12157613fd31f9e8959a7033b869d;p=motioneye-debian media browser file removal fix --- diff --git a/motioneye/mediafiles.py b/motioneye/mediafiles.py index bd8bbbe..138cb07 100644 --- a/motioneye/mediafiles.py +++ b/motioneye/mediafiles.py @@ -652,7 +652,13 @@ def get_media_preview(camera_config, path, media_type, width, height): return content sio = StringIO.StringIO(content) - image = Image.open(sio) + try: + image = Image.open(sio) + + except Exception as e: + logging.error('failed to open media preview image file: %s' % e) + return None + width = width and int(width) or image.size[0] height = height and int(height) or image.size[1] diff --git a/motioneye/static/js/main.js b/motioneye/static/js/main.js index 7cd3e2c..0b80c8a 100644 --- a/motioneye/static/js/main.js +++ b/motioneye/static/js/main.js @@ -3501,7 +3501,7 @@ function runMediaDialog(cameraId, mediaType) { function addEntries() { /* add the entries to the media list */ - entries.forEach(function (entry, i) { + entries.forEach(function (entry) { var entryDiv = entry.div; var detailsDiv = null; @@ -3534,7 +3534,10 @@ function runMediaDialog(cameraId, mediaType) { deleteButton.click(function () { doDeleteFile(basePath + mediaType + '/' + cameraId + '/delete' + entry.path, function () { entryDiv.remove(); - entries.splice(i, 1); /* remove entry from group */ + var pos = entries.indexOf(entry); + if (pos >= 0) { + entries.splice(pos, 1); /* remove entry from group */ + } /* update text on group button */ groupsDiv.find('div.media-dialog-group-button').each(function () {