Index: acidfree.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/acidfree/acidfree.install,v
retrieving revision 1.13
diff -u -p -r1.13 acidfree.install
--- acidfree.install	19 Feb 2007 00:55:13 -0000	1.13
+++ acidfree.install	25 Feb 2007 23:42:19 -0000
@@ -192,13 +192,16 @@ function acidfree_update_3_do_conversion
         $image = acidfree_update_3_node_load($image);
         foreach ($sizes as $size => $label) {
             $fmimage = db_fetch_object(db_query("SELECT * FROM {file} WHERE fid = '{$image->$size}'"));
-            if (strstr($fmimage->filename, 'tmp')) {
-                $pinfo = pathinfo($filename);
-                $fmimage = filemanager_rename($fmimage, "{$image->nid}_{$size}.{$pinfo['extension']}");
+            // continue only if file was really found
+            if ($fmimage) {
+                if (strstr($fmimage->filename, 'tmp')) {
+                    $pinfo = pathinfo($filename);
+                    $fmimage = filemanager_rename($fmimage, "{$image->nid}_{$size}.{$pinfo['extension']}");
+                }
+                $old_path = filemanager_create_path($fmimage);
+                _image_insert($image, $label, $old_path);
+                filemanager_delete($fmimage);
             }
-            $old_path = filemanager_create_path($fmimage);
-            _image_insert($image, $label, $old_path);
-            filemanager_delete($fmimage);
         }
         acidfree_update_3_node_common($image, $new_root);
     }
@@ -209,59 +212,62 @@ function acidfree_update_3_do_conversion
     /*
      * convert the videos
      */
-    _video_upload_check_settings();
     $videos = db_query("SELECT n.nid from {node} n JOIN {acidfree} a on n.nid = a.aid
                         WHERE type='acidfree' AND class='video'");
-    while ($video = db_fetch_array($videos)) {
-        $video = acidfree_update_3_node_load($video);
-        $video->type = 'video';
-        foreach (array_keys($sizes) as $size) {
-            $fmimage = db_fetch_object(db_query("SELECT * FROM {file} WHERE fid = '{$video->$size}'"));
-            switch ($size) {
-            case 'thumb':
-                break;
-            case 'small':
-                /* invoke the video_image stuff */
-                $file = (object)array(
-                        'filename' => $fmimage->filename,
-                        'filemime' => $fmimage->mimetype,
-                        'filesize' => $fmimage->size,
-                        'filepath' => filemanager_create_path($fmimage)
-                    );
-                $thumb = $video;
-                $thumb->type = 'image';
-                $thumb->promote = 0;
-                $thumb->taxonomy = array();
-                $thumb->sticky = 0;
-                unset($thumb->nid);
-                unset($thumb->vid);
-                image_prepare($thumb, $file);
-                $thumb = node_submit($thumb);
-                node_save($thumb);
-                $video->serial_data['iid'] = $thumb->nid;
-                $iminfo = image_get_info($file->filepath);
-                // we can do the lazy man way or we can extract info using ffmpeg on the video file
-                $video->videox = $iminfo->width;
-                $video->videoy = $iminfo->height;
-                break;
-            case 'large':
-                /* invoke the video_upload stuff */
-                $file = (object)array(
-                        'filename' => $fmimage->filename,
-                        'filemime' => $fmimage->mimetype,
-                        'filesize' => $fmimage->size,
-                        'filepath' => filemanager_create_path($fmimage)
-                    );
-                $_SESSION['video_upload_file'] = $file;
-                _video_upload_store($video);
+    // convert videos only if there's something to do
+    if (db_num_rows($videos) > 0) {
+        _video_upload_check_settings();
+        while ($video = db_fetch_array($videos)) {
+            $video = acidfree_update_3_node_load($video);
+            $video->type = 'video';
+            foreach (array_keys($sizes) as $size) {
+                $fmimage = db_fetch_object(db_query("SELECT * FROM {file} WHERE fid = '{$video->$size}'"));
+                switch ($size) {
+                case 'thumb':
+                    break;
+                case 'small':
+                    /* invoke the video_image stuff */
+                    $file = (object)array(
+                            'filename' => $fmimage->filename,
+                            'filemime' => $fmimage->mimetype,
+                            'filesize' => $fmimage->size,
+                            'filepath' => filemanager_create_path($fmimage)
+                        );
+                    $thumb = $video;
+                    $thumb->type = 'image';
+                    $thumb->promote = 0;
+                    $thumb->taxonomy = array();
+                    $thumb->sticky = 0;
+                    unset($thumb->nid);
+                    unset($thumb->vid);
+                    image_prepare($thumb, $file);
+                    $thumb = node_submit($thumb);
+                    node_save($thumb);
+                    $video->serial_data['iid'] = $thumb->nid;
+                    $iminfo = image_get_info($file->filepath);
+                    // we can do the lazy man way or we can extract info using ffmpeg on the video file
+                    $video->videox = $iminfo->width;
+                    $video->videoy = $iminfo->height;
+                    break;
+                case 'large':
+                    /* invoke the video_upload stuff */
+                    $file = (object)array(
+                            'filename' => $fmimage->filename,
+                            'filemime' => $fmimage->mimetype,
+                            'filesize' => $fmimage->size,
+                            'filepath' => filemanager_create_path($fmimage)
+                        );
+                    $_SESSION['video_upload_file'] = $file;
+                    _video_upload_store($video);
+                }
+                filemanager_delete($fmimage);
             }
-            filemanager_delete($fmimage);
+            acidfree_update_3_node_common($video, $new_root);
+            video_insert($video);
         }
-        acidfree_update_3_node_common($video, $new_root);
-        video_insert($video);
+        db_query("UPDATE {node} n JOIN {acidfree} a ON n.nid=a.aid SET n.type='video' WHERE n.type='acidfree' AND a.class='video'");
+        drupal_set_message('finished updating videos');
     }
-    db_query("UPDATE {node} n JOIN {acidfree} a ON n.nid=a.aid SET n.type='video' WHERE n.type='acidfree' AND a.class='video'");
-    drupal_set_message('finished updating videos');
 }
 
 if (count($missing = acidfree_update_3_okay()) == 0) {
