Index: trunk/ippTools/src/pzgetimfiles.c
===================================================================
--- trunk/ippTools/src/pzgetimfiles.c	(revision 10404)
+++ trunk/ippTools/src/pzgetimfiles.c	(revision 10405)
@@ -215,5 +215,5 @@
     {
         char *query = 
-            "CREATE TEMPORARY TABLE incoming (exp_id VARCHAR(64), camera VARCHAR(64), telescope VARCHAR(64), bytes INT, md5sum VARCHAR(32), class VARCHAR(64), class_id VARCHAR(64), uri VARCHAR(255), PRIMARY KEY(exp_id, camera, telescope, class, class_id)) ENGINE=MEMORY";
+            "CREATE TEMPORARY TABLE incoming (exp_id VARCHAR(64), camera VARCHAR(64), telescope VARCHAR(64), file_id VARCHAR(64), bytes INT, md5sum VARCHAR(32), class VARCHAR(64), class_id VARCHAR(64), uri VARCHAR(255), PRIMARY KEY(exp_id, camera, telescope, class, class_id)) ENGINE=MEMORY";
 
         if (!p_psDBRunQuery(config->dbh, query)) {
@@ -230,5 +230,5 @@
     // load the imfiles (files) into the temp table
     {
-        char *query = "INSERT INTO incoming (exp_id, camera, telescope, bytes, md5sum, class, class_id, uri) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
+        char *query = "INSERT INTO incoming (exp_id, camera, telescope, file_id, bytes, md5sum, class, class_id, uri) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
 
         long inserted = p_psDBRunQueryPrepared(config->dbh, newImfiles, query);
@@ -303,4 +303,5 @@
             "       incoming.bytes,"
             "       incoming.md5sum,"
+            "       incoming.file_id,"
             "       incoming.class,"
             "       incoming.class_id,"
@@ -569,6 +570,10 @@
         // check that we have the right number of tokens
         // print "# uri fileid bytes md5sum type \n";
-        if (psListLength(tokens) != 5) {
+        if (!psListLength(tokens) > 5) {
             psError(PS_ERR_UNKNOWN, true, "invalid line format: %s", line);
+            psFree(tokens);
+            psFree(pzPendingImfiles);                
+            psFree(lineCursor);
+            psFree(doc);
             return false;
         }
@@ -577,8 +582,9 @@
         psListIterator *tokenCursor = psListIteratorAlloc(tokens, 0, false);
         char *uri       = psListGetAndIncrement(tokenCursor);
-        char *class_id  = psListGetAndIncrement(tokenCursor); // fileid
+        char *file_id   = psListGetAndIncrement(tokenCursor); // fileid
         char *bytes     = psListGetAndIncrement(tokenCursor); // bytes
         char *md5sum    = psListGetAndIncrement(tokenCursor); // md5sum
         char *class     = psListGetAndIncrement(tokenCursor); // type
+        char *class_id  = psListGetAndIncrement(tokenCursor); // chipname
 
         // create a new metadata to represent this line and it's values
@@ -600,4 +606,11 @@
         if (!psMetadataAddStr(md, PS_LIST_TAIL, "telescope", 0, NULL, telescope)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item telescope");
+            psFree(md);
+            psFree(tokenCursor);
+            psFree(tokens);
+            return NULL;
+        }
+        if (!psMetadataAddStr(md, PS_LIST_TAIL, "file_id", 0, NULL, file_id)) {
+            psError(PS_ERR_UNKNOWN, false, "failed to add item bytes");
             psFree(md);
             psFree(tokenCursor);
