Index: trunk/psModules/src/detrend/pmDetrendDB.c
===================================================================
--- trunk/psModules/src/detrend/pmDetrendDB.c	(revision 15562)
+++ trunk/psModules/src/detrend/pmDetrendDB.c	(revision 15812)
@@ -253,5 +253,5 @@
     psStringAppend (&line, "detselect -select %s", detID);
     if (classID && strlen(classID) > 0) {
-        psStringAppend(&line, " -class_id %s", classID);
+	psStringAppend(&line, " -class_id %s", classID);
     }
     pmConfigDatabaseCommand(&line, config);
@@ -285,4 +285,10 @@
         goto failure;
     }
+    psMetadataItem *item = psMetadataLookup (answer, "detNormalizedImfile");
+    if ((item->type == PS_DATA_METADATA_MULTI) && (item->data.list->n > 1)) {
+	psError(PS_ERR_IO, false, "detselect returned too many files\n");
+        goto failure;
+    }
+
     psMetadata *md = psMetadataLookupPtr (NULL, answer, "detNormalizedImfile");
     if (!md) {
