Changeset 2934

Show
Ignore:
Timestamp:
04/25/06 10:47:37 (3 years ago)
Author:
madcat
Message:

No longer loses custom metadata after file rehash.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • hydranode/hncore/metadata.cpp

    r2694 r2934  
    10291029        getEventTable().postEvent(this, MD_ADDED_IMAGE); 
    10301030} 
     1031 
     1032void MetaData::mergeCustom(MetaData *other) { 
     1033        CHECK_THROW(other); 
     1034 
     1035        m_fileNames  = other->m_fileNames; 
     1036        m_customData = other->m_customData; 
     1037        m_comments   = other->m_comments; 
     1038} 
  • hydranode/hncore/metadata.h

    r2924 r2934  
    584584        //@} 
    585585 
     586        /** 
     587         * Merges names, comments and custom fields from other metadata to 
     588         * this metadata. 
     589         * 
     590         * \note All existing names, comments and custom fields in this object 
     591         *       are destroyed. 
     592         */ 
     593        void mergeCustom(MetaData *other); 
    586594private: 
    587595        MetaData(const MetaData &md);             //!< Copy construct forbidden 
  • hydranode/hncore/sharedfile.cpp

    r2894 r2934  
    449449                ) % hw->getFileName().native_file_string()); 
    450450                destroy(); 
    451         } else if (m_metaData) { 
    452                 logDebug("TODO! Implement MetaData combining."); 
    453451        } else { 
    454452                CHECK_THROW(hw->getMetaData()); 
    455453                CHECK_THROW(hw->getMetaData()->getHashSetCount()); 
     454                MetaData *nmd = hw->getMetaData(); 
     455                MetaData *found = 0; 
     456                for (uint32_t i = 0; i < nmd->getHashSetCount(); ++i) { 
     457                        found = MetaDb::instance().find( 
     458                                nmd->getHashSet(i)->getFileHash() 
     459                        ); 
     460                        if (found) { 
     461                                break; 
     462                        } 
     463                } 
     464                if (found) { 
     465                        logDebug( 
     466                                boost::format( 
     467                                        "Found existing MetaData for file " 
     468                                        "%s, merging custom data." 
     469                                ) % getName() 
     470                        ); 
     471                        nmd->mergeCustom(found); 
     472                        // TODO: remove the found entry from MetaDb 
     473                } 
     474 
    456475                m_metaData = hw->getMetaData(); 
    457476                m_metaData->setName(getName());