--- mm_content.module	Thu Dec 04 17:59:16 2008
+++ mm_content.new	Thu Dec 04 18:00:14 2008
@@ -133,31 +133,43 @@ function mm_content_harvest($action, $co
   $files = array();
   $fields = content_fields();
 
+  $harvest_conditions = '';
   // are we harvesting from a specific NID ?
   if ($nid) {
     $harvest_conditions = ' AND n.nid = '. $nid;
   }
   else {
-    // select nodes that have beend modified since the last time that this
-    // configuration was run
-    $harvest_conditions = ' AND n.changed > '. ($running_config->last_start_time ? $running_config->last_start_time : 0);
+    // select nodes where file to harvest have beend modified since the last
+    // time that this configuration was run
+    $harvest_conditions .= ' AND f.timestamp > '. ($running_config->last_start_time ? $running_config->start_time : 0);
   }
 
   foreach ($configuration['mm_config_harvest_field'] as $field_name) {
     $db_info = content_database_info($fields[$field_name]);
 
-    // @TODO this has to be adapted for D6 SQL structure
-    $results = db_query('SELECT f.filepath, n.nid FROM {files} f
-      LEFT JOIN '. $db_info['table'] .' c ON c.'. $db_info['columns']['fid']['column'] .' = f.fid
-      LEFT JOIN {node} n ON c.nid = n.nid
-      LEFT JOIN {media_mover_files} m ON m.fid = f.fid AND m.cid = %d
-      WHERE  m.mmfid IS NULL '. $harvest_conditions .'
-      ORDER BY n.nid DESC', $configuration['cid'], $running_config->last_start_time);
-    while ($result = db_fetch_array($results)) {
-      $files[] = array(
-        'harvest_file' => $result['filepath'],
-        'nid' => $result['nid'],
-      );
+    switch ($fields[$field_name]['type']) {
+      case 'text':
+        //$node->{$field['field_name']} = array(array('value' => $file['process_file']));
+      break;
+    
+      // handle image field case
+      case 'filefield':
+      case 'image':
+        // @TODO this has to be adapted for D6 SQL structure
+        $results = db_query('SELECT f.filepath, n.nid, f.timestamp FROM {files} f
+          LEFT JOIN '. $db_info['table'] .' c ON c.'. $db_info['columns']['fid']['column'] .' = f.fid
+          LEFT JOIN {node} n ON c.nid = n.nid
+          LEFT JOIN {media_mover_files} m ON m.fid = f.fid AND m.cid = %d
+          WHERE  m.mmfid IS NULL '. $harvest_conditions .'
+          ORDER BY n.nid DESC', $configuration['cid'], $running_config->last_start_time);
+        while ($result = db_fetch_array($results)) {
+          drupal_set_message($result['timestamp'] .' > '. $running_config->last_start_time);
+          $files[] = array(
+            'harvest_file' => $result['filepath'],
+            'nid' => $result['nid'],
+          );
+        }
+      break;
     }
   }
 
@@ -195,7 +207,7 @@ function mm_content_node_save($configura
     // clear the cache
     cache_clear_all('content:'. $node->nid .':'. $node->vid, 'cache_content');
     // return the file
-    return $file['storage_file'];
+    return $file['storage_file'] = $file['process_file'];
 	}
 	// set an alert
 	watchdog('mm_content', 'Media Mover did not pass a node ID for storing data in a CCK field: !file', array('!file', l(t($file['mmfid']), 'admin/media_mover/file/edit/'. $file['mmfid'])));
