--- nodecomment.convert.inc.orig	2009-08-11 23:45:05.786776037 -0700
+++ nodecomment.convert.inc	2009-08-11 23:45:00.286771206 -0700
@@ -229,6 +229,17 @@ function nodecomment_convert_batch_proce
         $comment->status = $item->moderate;
       }
 
+	  // Make comment_upload.module happy - convert each file entry to array instead of object.
+      if (isset($comment->files) && count($comment->files)) {
+        $new_files = array();
+        foreach ($comment->files as $key => $file) {
+		  $file = (array)$file;
+          $file['new'] = TRUE;	// Flag file as new for comment_upload.module, so it will register it.
+          $new_files[$key] = $file;
+        }
+        $comment->files = $new_files;
+      }
+
       // Insert the new comment.
       $edit = (array) $comment;
       db_query("INSERT INTO {comments} (nid, pid, uid, subject, comment, format, hostname, timestamp, status, thread, name, mail, homepage) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s')", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], $edit['hostname'], $edit['timestamp'], $edit['status'], $edit['thread'], $edit['name'], $edit['mail'], $edit['homepage']);
@@ -247,6 +258,10 @@ function nodecomment_convert_batch_proce
       db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
       db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
 
+      // Prevent file attachments from being deleted.
+      $node->files = array();
+      db_query('DELETE FROM {upload} WHERE nid = %d', $node->nid);
+
       // Call the node-specific callback (if any):
       node_invoke($node, 'delete');
       node_invoke_nodeapi($node, 'delete');
@@ -270,14 +285,33 @@ function nodecomment_convert_batch_proce
         $node->changed = $item->timestamp;
         $node->status = 1;
         $node->moderate = module_exists('modr8') ? $item->status : 0;
+        // Ask comment_upload.module to load files
+        if (function_exists('comment_upload_load_files')) {
+          $node->files = comment_upload_load_files($item->cid);
+        }
       }
       $node->type = $comment_type;
 
+	  // Make upload.module happy - convert each file entry to object instead of array.
+      if (isset($node->files) && count($node->files)) {
+        $new_files = array();
+        foreach ($node->files as $key => $file) {
+		  $file = (object)$file;
+          $file->new = TRUE;	// Flag file as new for upload.module, so it will register it.
+          $new_files[$key] = $file;
+        }
+        $node->files = $new_files;
+      }
+
       node_save($node);
 
       // If converting from comments to node comments, delete the comment row.
       if ($previous_comment_type == '' && $comment_type) {
         db_query("DELETE FROM {comments} WHERE cid = %d", $item->cid);
+
+        // Prevent file attachments from being deleted.
+        $edit->files = array();
+        db_query('DELETE FROM {comment_upload} WHERE cid = %d', $item->cid);
         comment_invoke_comment($item, 'delete');
       }
     }
