src/main/java/com/conveyal/gtfs/loader/JdbcGtfsLoader.java
private void registerFeed (File gtfsFile) {

        // FIXME is this extra CSV reader used anymore? Check comment below.
        // First, inspect feed_info.txt to extract the ID and version.
        // We could get this with SQL after loading, but feed_info, feed_id and feed_version are all optional.
        CsvReader csvReader = Table.FEED_INFO.getCsvReader(zip, errorStorage);
        String feedId = "", feedVersion = "";
        if (csvReader != null) {
            // feed_info.txt has been found and opened.
            try {
                csvReader.readRecord();
                // csvReader.get() returns the empty string for missing columns
                feedId = csvReader.get("feed_id");
                feedVersion = csvReader.get("feed_version");
            } catch (IOException e) {
                LOG.error("Exception while inspecting feed_info: {}", e);
            }
            csvReader.close();
        }

        try {
            HashCode md5 = Files.hash(gtfsFile, Hashing.md5());
            String md5Hex = md5.toString();
            HashCode sha1 = Files.hash(gtfsFile, Hashing.sha1());
            String shaHex = sha1.toString();
            createFeedRegistryIfNotExists(connection);
            // TODO try to get the feed_id and feed_version out of the feed_info table
            // statement.execute("select * from feed_info");

            // current_timestamp seems to be the only standard way to get the current time across all common databases.
            // Record total load processing time?
            PreparedStatement insertStatement = connection.prepareStatement(
                    "insert into feeds values (?, ?, ?, ?, ?, ?, current_timestamp, null)");
            insertStatement.setString(1, tablePrefix);
            insertStatement.setString(2, md5Hex);
            insertStatement.setString(3, shaHex);
            insertStatement.setString(4, feedId.isEmpty() ? null : feedId);
            insertStatement.setString(5, feedVersion.isEmpty() ? null : feedVersion);
            insertStatement.setString(6, zip.getName());
            insertStatement.execute();
            connection.commit();
            LOG.info("Created new feed namespace: {}", insertStatement);
        } catch (Exception ex) {
            LOG.error("Exception while registering new feed namespace in feeds table", ex);
            DbUtils.closeQuietly(connection);
        }
    }
private void registerFeed (File gtfsFile) {

        // FIXME is this extra CSV reader used anymore? Check comment below.
        // First, inspect feed_info.txt to extract the ID and version.
        // We could get this with SQL after loading, but feed_info, feed_id and feed_version are all optional.
        CsvReader csvReader = Table.FEED_INFO.getCsvReader(zip, errorStorage);
        String feedId = "", feedVersion = "";
        if (csvReader != null) {
            // feed_info.txt has been found and opened.
            try {
                csvReader.readRecord();
                // csvReader.get() returns the empty string for missing columns
                feedId = csvReader.get("feed_id");
                feedVersion = csvReader.get("feed_version");
            } catch (IOException e) {
                LOG.error("Exception while inspecting feed_info: {}", e);
            }
            csvReader.close();
        }

        try {
            HashCode md5 = Files.hash(gtfsFile, Hashing.md5());
            String md5Hex = md5.toString();
            HashCode sha1 = Files.hash(gtfsFile, Hashing.sha1());
            String shaHex = sha1.toString();
            createFeedRegistryIfNotExists(connection);
            // TODO try to get the feed_id and feed_version out of the feed_info table
            // statement.execute("select * from feed_info");

            // current_timestamp seems to be the only standard way to get the current time across all common databases.
            // Record total load processing time?
            PreparedStatement insertStatement = connection.prepareStatement(
                    "insert into feeds values (?, ?, ?, ?, ?, ?, current_timestamp, null)");
            insertStatement.setString(1, tablePrefix);
            insertStatement.setString(2, md5Hex);
            insertStatement.setString(3, shaHex);
            insertStatement.setString(4, feedId.isEmpty() ? null : feedId);
            insertStatement.setString(5, feedVersion.isEmpty() ? null : feedVersion);
            insertStatement.setString(6, zip.getName());
            insertStatement.execute();
            connection.commit();
            LOG.info("Created new feed namespace: {}", insertStatement);
        } catch (Exception ex) {
            LOG.error("Exception while registering new feed namespace in feeds table", ex);
            DbUtils.closeQuietly(connection);
        }
    }
private void registerFeed ( File gtfsFile ) { // FIXME is this extra CSV reader used anymore? Check comment below. // First, inspect feed_info.txt to extract the ID and version. // We could get this with SQL after loading, but feed_info, feed_id and feed_version are all optional. CsvReader csvReader = Table . FEED_INFO . getCsvReader ( zip , errorStorage ) ; String feedId = "" , feedVersion = "" ; if ( csvReader != null ) { // feed_info.txt has been found and opened. try { csvReader . readRecord ( ) ; // csvReader.get() returns the empty string for missing columns feedId = csvReader . get ( "feed_id" ) ; feedVersion = csvReader . get ( "feed_version" ) ; } catch ( IOException e ) { LOG . error ( "Exception while inspecting feed_info: {}" , e ) ; } csvReader . close ( ) ; } try { HashCode md5 = Files . hash ( gtfsFile , Hashing . md5 ( ) ) ; String md5Hex = md5 . toString ( ) ; HashCode sha1 = Files . hash ( gtfsFile , Hashing . sha1 ( ) ) ; String shaHex = sha1 . toString ( ) ; createFeedRegistryIfNotExists ( connection ) ; // TODO try to get the feed_id and feed_version out of the feed_info table // statement.execute("select * from feed_info"); // current_timestamp seems to be the only standard way to get the current time across all common databases. // Record total load processing time? PreparedStatement insertStatement = connection . prepareStatement ( "insert into feeds values (?, ?, ?, ?, ?, ?, current_timestamp, null)" ) ; insertStatement . setString ( 1 , tablePrefix ) ; insertStatement . setString ( 2 , md5Hex ) ; insertStatement . setString ( 3 , shaHex ) ; insertStatement . setString ( 4 , feedId . isEmpty ( ) ? null : feedId ) ; insertStatement . setString ( 5 , feedVersion . isEmpty ( ) ? null : feedVersion ) ; insertStatement . setString ( 6 , zip . getName ( ) ) ; insertStatement . execute ( ) ; connection . commit ( ) ; LOG . info ( "Created new feed namespace: {}" , insertStatement ) ; } catch ( Exception ex ) { LOG . error ( "Exception while registering new feed namespace in feeds table" , ex ) ; DbUtils . closeQuietly ( connection ) ; } }
Add a line to the list of loaded feeds showing that this feed has been loaded.
We used to inspect feed_info here so we could make our table prefix based on feed ID and version.
Now we just load feed_info like any other table.
// Create a row in the table of loaded feeds for this feed
Really this is not just making the table prefix - it's loading the feed_info and should also calculate hashes.

Originally we were flattening all feed_info files into one root-level table, but that forces us to drop any
custom fields in feed_info.
Add a line to the list of loaded feeds showing that this feed has been loaded . We used to inspect feed_info here so we could make our table prefix based on feed ID and version . Now we just load feed_info like any other table . // Create a row in the table of loaded feeds for this feed Really this is not just making the table prefix - it s loading the feed_info and should also calculate hashes .