]> www.vanbest.org Git - motioneye-debian/commitdiff
media browser file removal fix
authorCalin Crisan <ccrisan@gmail.com>
Fri, 25 Dec 2015 19:50:34 +0000 (21:50 +0200)
committerCalin Crisan <ccrisan@gmail.com>
Fri, 25 Dec 2015 19:50:34 +0000 (21:50 +0200)
motioneye/mediafiles.py
motioneye/static/js/main.js

index bd8bbbe2a55da19ac7c6cae8fb3344e667e543ba..138cb074d70da8737370cbc3598963583cc39a5d 100644 (file)
@@ -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]
     
index 7cd3e2c357c3389b20a48a75d9f70c14cebbabd3..0b80c8a0bf44ad540a8fbbf1d9553dbbbfdfa5fc 100644 (file)
@@ -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 () {