--- feeds/plugins/FeedsNodeProcessor.inc	Thu Nov 12 11:46:16 2009
+++ feeds/plugins/FeedsNodeProcessor.inc	Fri Nov 13 15:58:34 2009
@@ -23,27 +23,39 @@
       // If the target item does not exist OR if update_existing is enabled,
       // map and save.
       if (!($nid = $this->existingItemId($item, $source)) || $this->config['update_existing']) {
+        $hash = $this->hash($item);
+        $node = new stdClass();
 
-        // Map item to a node.
-        $node = $this->map($item);
+        if (!empty($nid)) {
+          if ($hash == $this->getHash($nid)) {
+            // No change, nothing to do.
+            continue;
+          }
+          $node->nid = $nid;
+          $updated++;
+        }
+        else {
+          $created++;
+        }
+        
+        $node->type = $this->config['content_type'];
+        $node->feeds_node_item = new stdClass();
+        $node->feeds_node_item->hash = $hash;
+         
+        // Execute mappings from $item to $node.
+        $this->map($item, $node);
 
         // Add some default information.
         $node->feeds_node_item->id = $this->id;
         $node->feeds_node_item->imported = FEEDS_REQUEST_TIME;
         $node->feeds_node_item->feed_nid = $source->feed_nid;
-        if (!empty($nid)) {
-          $node->nid = $nid;
-        }
+        
+        // Assign an aggregated node always to anonymous.
+        // @todo: change to feed node uid to keep in line with feedapi?
+        $node->uid = 0;
 
         // Save the node.
         node_save($node);
-
-        if ($nid) {
-          $updated++;
-        }
-        else {
-          $created++;
-        }
       }
     }
 
@@ -105,20 +117,15 @@
   /**
    * Execute mapping on an item.
    */
-  protected function map($source_item) {
+  protected function map($source_item, $target_node) {
     // Prepare node object.
     static $included;
     if (!$included) {
       module_load_include('inc', 'node', 'node.pages');
       $included = TRUE;
     }
-    $target_node = new stdClass();
-    $target_node->type = $this->config['content_type'];
-    $target_node->feeds_node_item = new stdClass();
     node_object_prepare($target_node);
-    // Assign an aggregated node always to anonymous.
-    // @todo: change to feed node uid to keep in line with feedapi.
-    $target_node->uid = 0;
+    $target_node->log = 'Created/updated by FeedsNodeProcessor';
 
     // Load all mappers. parent::map() might invoke their callbacks.
     self::loadMappers();
@@ -312,7 +319,33 @@
     }
     $loaded = TRUE;
   }
-}
+   /**
+   * Create MD5 hash of $item array.
+   */
+   protected function hash($item) {
+    $to_hash = '';
+    if(is_array($item)) {
+      foreach($item as $val) {
+        $to_hash .= $val;
+      }
+    }
+    else {
+      return FALSE;
+    }
+    return hash('md5', $to_hash);
+  }
+  /**
+   * Retrieve MD5 hash of $nid from DB.
+   */
+  protected function getHash($nid) {
+    $hash = db_result(db_query('SELECT hash FROM {feeds_node_item} WHERE nid = %d', $nid));
+    if ($hash) {
+      // Return with the hash
+      return $hash;
+    }
+    return 0; //Or FALSE?
+  }
+} //class FeedsNodeProcessor
 
 /**
  * Copy of node_delete() that circumvents node_access().
