]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/Main.hs
Fix deletion of unsupported document types.
[dead/htsn-import.git] / src / Main.hs
index e36cc789b4d2f2dbfa485e9af9326a2e63da4824..907c3517b8a28c034605f9608595bc8ef17c4358 100644 (file)
@@ -110,9 +110,13 @@ import_file cfg path = do
   results <- parse_and_import `catch` exception_handler
   case results of
     []    -> do
-      -- One of the arrows returned "nothing."
-      report_error $ "Unable to determine DTD for file " ++ path ++ "."
-      return False
+      -- One of the arrows returned "nothing."  Now that we're
+      -- validating against the DTDs, this will almost always be
+      -- caused by a document whose DTD is not present (i.e. is
+      -- unsupported). So we return "success" to allow the XML file to
+      -- be deleted.
+      report_error $ "No DTD for file " ++ path ++ "."
+      return True
     (ImportFailed errmsg:_) -> do
       report_error $ errmsg ++ " (" ++ path ++ ")"
       return False
@@ -289,6 +293,10 @@ import_file cfg path = do
             | otherwise = do
               let infomsg =
                     "Unrecognized DTD in " ++ path ++ ": " ++ dtd ++ "."
+              -- This should be an impossible case while DTD
+              -- validation is enabled. If we can parse the file at
+              -- all, then we have a DTD for it sitting around. And we
+              -- only have DTDs for supported types.
               return $ ImportUnsupported infomsg