--- plugins/FeedsNodeProcessor.inc	2010-02-10 18:49:35.000000000 -0500
+++ plugins/FeedsNodeProcessorNew.inc	2010-03-07 19:56:39.000000000 -0500
@@ -21,6 +21,9 @@ class FeedsNodeProcessor extends FeedsPr
 
     // Keep track of processed items in this pass.
     $processed = 0;
+    if (empty($batch->touched)) {
+      $batch->touched = 0;
+    }
 
     while ($item = $batch->shiftItem()) {
 
@@ -35,6 +38,12 @@ class FeedsNodeProcessor extends FeedsPr
           // If hash of this item is same as existing hash there is no actual
           // change, skip.
           if ($hash == $this->getHash($nid)) {
+            // touch imported timestamp for node
+            $update = new stdClass();
+            $update->nid = $nid;
+            $update->imported = FEEDS_REQUEST_TIME;
+            drupal_write_record('feeds_node_item', $update, 'nid');
+            $batch->touched++;
             continue;
           }
 
@@ -83,10 +92,13 @@ class FeedsNodeProcessor extends FeedsPr
     if ($batch->created) {
       drupal_set_message(t('Created !number !type nodes.', array('!number' => $batch->created, '!type' => node_get_types('name', $this->config['content_type']))));
     }
-    elseif ($batch->updated) {
+    if ($batch->updated) {
       drupal_set_message(t('Updated !number !type nodes.', array('!number' => $batch->updated, '!type' => node_get_types('name', $this->config['content_type']))));
     }
-    else {
+    if ($batch->touched) {
+      drupal_set_message(t('Touched !number !type nodes.', array('!number' => $batch->touched, '!type' => node_get_types('name', $this->config['content_type']))));
+    }
+    if (!($batch->created || $batch->updated || $batch->touched)) {
       drupal_set_message(t('There is no new content.'));
     }
 
@@ -130,12 +142,26 @@ class FeedsNodeProcessor extends FeedsPr
     if ($time == FEEDS_EXPIRE_NEVER) {
       return;
     }
-    $result = db_query_range('SELECT n.nid FROM {node} n JOIN {feeds_node_item} fni ON n.nid = fni.nid WHERE fni.id = "%s" AND n.created < %d', $this->id, FEEDS_REQUEST_TIME - $time, 0, variable_get('feeds_node_batch_size', FEEDS_NODE_BATCH_SIZE));
-    while ($node = db_fetch_object($result)) {
-      _feeds_node_delete($node->nid);
-    }
-    if (db_result(db_query_range('SELECT n.nid FROM {node} n JOIN {feeds_node_item} fni ON n.nid = fni.nid WHERE fni.id = "%s" AND n.created < %d', $this->id, FEEDS_REQUEST_TIME - $time, 0, 1))) {
-      return FEEDS_BATCH_ACTIVE;
+    switch ($this->expirySource()) {
+      case 'import':
+        $result = db_query_range('SELECT fni.nid FROM {feeds_node_item} fni WHERE fni.id = "%s" AND fni.imported < %d', $this->id, FEEDS_REQUEST_TIME - $time, 0, variable_get('feeds_node_batch_size', FEEDS_NODE_BATCH_SIZE));
+        while ($fni = db_fetch_object($result)) {
+          _feeds_node_delete($fni->nid);
+        }
+        if (db_result(db_query_range('SELECT fni.nid FROM {feeds_node_item} fni WHERE fni.id = "%s" AND fni.imported < %d', $this->id, FEEDS_REQUEST_TIME - $time, 0, 1))) {
+          return FEEDS_BATCH_ACTIVE;
+        }
+        break;
+      case 'publish':
+      default:
+        $result = db_query_range('SELECT n.nid FROM {node} n JOIN {feeds_node_item} fni ON n.nid = fni.nid WHERE fni.id = "%s" AND n.created < %d', $this->id, FEEDS_REQUEST_TIME - $time, 0, variable_get('feeds_node_batch_size', FEEDS_NODE_BATCH_SIZE));
+        while ($node = db_fetch_object($result)) {
+          _feeds_node_delete($node->nid);
+        }
+        if (db_result(db_query_range('SELECT n.nid FROM {node} n JOIN {feeds_node_item} fni ON n.nid = fni.nid WHERE fni.id = "%s" AND n.created < %d', $this->id, FEEDS_REQUEST_TIME - $time, 0, 1))) {
+          return FEEDS_BATCH_ACTIVE;
+        }
+        break;
     }
     return FEEDS_BATCH_COMPLETE;
   }
@@ -156,6 +182,13 @@ class FeedsNodeProcessor extends FeedsPr
   }
 
   /**
+   * Return expiry source.
+   */
+  public function expirySource() {
+    return $this->config['expire_source'];
+  }
+
+  /**
    * Override parent::configDefaults().
    */
   public function configDefaults() {
@@ -165,6 +198,7 @@ class FeedsNodeProcessor extends FeedsPr
       'content_type' => $type,
       'update_existing' => 0,
       'expire' => FEEDS_EXPIRE_NEVER,
+      'expire_source' => 'publish',
       'mappings' => array(),
     );
   }
@@ -193,9 +227,19 @@ class FeedsNodeProcessor extends FeedsPr
       '#type' => 'select',
       '#title' => t('Expire nodes'),
       '#options' => $period,
-      '#description' => t('Select after how much time nodes should be deleted. The node\'s published date will be used for determining the node\'s age, see Mapping settings.'),
+      '#description' => t('Select after how much time nodes should be deleted. The expire source determines the node\'s age.'),
       '#default_value' => $this->config['expire'],
     );
+    $form['expire_source'] = array(
+      '#type' => 'select',
+      '#title' => t('Expire source'),
+      '#options' => array(
+        'publish' => t('Published Date'),
+        'import' => t('Imported Date'),
+      ),
+      '#description' => t('Choose either the node\'s published date or last imported date for determining the node\'s age.'),
+      '#default_value' => $this->config['expire_source'],
+    );
     return $form;
   }
 
