Commit ef982652 authored by Andrea Bignamini's avatar Andrea Bignamini
Browse files

Add checksum_gz and check on checksum columns

In WorkerThread the checksum_gz is implemented as the checksum.
DMDBVerifier now checks that all tables in metadata has the columns
checksum and checksum_gz.
parent 37887d88
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -95,6 +95,8 @@ void DMDBVerifier::testInstrumentMapping(Instrument::SP instrument_sp)
        testColumnDefinition(columnTuple_vector,"file_path","varchar", false);
        testColumnDefinition(columnTuple_vector,"file_version","smallint", true);
        testColumnDefinition(columnTuple_vector,"file_name","varchar", true);
        testColumnDefinition(columnTuple_vector,"checksum","varchar", false);
        testColumnDefinition(columnTuple_vector,"checksum_gz","varchar", false);
        testColumnDefinition(columnTuple_vector,"update_time","timestamp", true);

        //Check mapping columns in table definition
+1 −1
Original line number Diff line number Diff line
@@ -2,6 +2,6 @@
#if !defined(VERSION_H)
#define VERSION_H 1

std::string version = "2.0.0-alpha";
std::string version = "2.0.0-rc.1";

#endif
+10 −3
Original line number Diff line number Diff line
@@ -405,11 +405,14 @@ void WorkerThread::processFits(boost::filesystem::path& origPath,
	//Copy file to archive storage
	copyFile(origPath, destPath);
	
	//Compute checksum_gz
	std::string checksum_gz = computeMd5(destPath);

	//Don't add the file to metadata if duplidateMax=-1 (i.e. if it already exists with the same checksum)
	if(duplicateMax!=-1)
	  {
	    //Create metadata query
	    std::string query = composeQuery(destination_sp, date, duplicateMax, checksum,
	    std::string query = composeQuery(destination_sp, date, duplicateMax, checksum, checksum_gz,
					     origPath, fitsFile_sp, readHDUSet);

	    try
@@ -494,8 +497,8 @@ int WorkerThread::findDuplicateMax(ConnectionManager::SessionSP session_sp,
//	WorkerThread::composeQuery()
//==============================================================================
std::string WorkerThread::composeQuery(Destination::SP destination_sp,
    boost::gregorian::date& date, int duplicateMax, std::string checksum, boost::filesystem::path& origPath,
    boost::shared_ptr<CCfits::FITS> fitsFile_sp, std::set<int>& readHDUSet)
    boost::gregorian::date& date, int duplicateMax, std::string checksum, std::string checksum_gz,
    boost::filesystem::path& origPath, boost::shared_ptr<CCfits::FITS> fitsFile_sp, std::set<int>& readHDUSet)
	throw(CCfits::FitsException, std::runtime_error)
{
    DEBUG_STREAM << "WorkerThread::composeQuery()" << endl;
@@ -517,6 +520,10 @@ std::string WorkerThread::composeQuery(Destination::SP destination_sp,
	insertQuery << "," << destination_sp->getTable() << ".checksum";
	valuesQuery << ",\'" << checksum << "\'";

	//Append checksum_gz
	insertQuery << "," << destination_sp->getTable() << ".checksum_gz";
	valuesQuery << ",\'" << checksum_gz << "\'";

	//Append file path column to query
	insertQuery << "," << destination_sp->getTable() << ".file_path";
	int month = date.month();
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ protected:
//	[Protected] Metadata archiving methods
//------------------------------------------------------------------------------
	virtual std::string composeQuery(Destination::SP, boost::gregorian::date&,
        int, std::string, boost::filesystem::path&, boost::shared_ptr<CCfits::FITS>,
        int, std::string, std::string, boost::filesystem::path&, boost::shared_ptr<CCfits::FITS>,
        std::set<int>&) throw(CCfits::FitsException, std::runtime_error);

    virtual void fillQueryFromFits(std::stringstream&, std::stringstream&,