#include <sharedfile.h>
Inheritance diagram for SharedFile:


It may be partial or complete or completely empty. SharedFile objects are owned by FilesList class - the destructor of SharedFile has been protected to avoid unwanted deletion of SharedFile objects.
Definition at line 50 of file sharedfile.h.
Public Member Functions | |
| DECLARE_EVENT_TABLE (SharedFile *, int) | |
| SharedFile (boost::filesystem::path location, MetaData *metaData=0) | |
| Construct SharedFile object. | |
| SharedFile (PartData *partData, MetaData *metaData=0) | |
| Construct SharedFile from existing PartData. | |
| void | destroy () |
| Schedule for destruction. | |
| void | verify () |
| Order the SharedFile to re-check the integrity of the physical file, and up2date metadata. | |
| std::string | read (uint64_t begin, uint64_t end) |
| Read data from disk from location and return it. | |
Accessors | |
| std::string | getLocation () const |
| std::string | getName () const |
| Retrieve the name of this object. | |
| boost::filesystem::path | getPath () const |
| MetaData * | getMetaData () const |
| PartData * | getPartData () const |
| uint64_t | getUploaded () const |
| uint64_t | getSize () const |
| bool | hasMetaData () const |
| bool | isComplete () const |
| bool | isPartial () const |
Setters | |
| void | setMetaData (MetaData *md) |
| void | setPartData (PartData *pd) |
| void | addUploaded (uint64_t sum) |
Private Member Functions | |
| ~SharedFile () | |
| Allowed by FilesList. | |
| SharedFile () | |
| Forbidden. | |
| SharedFile (SharedFile &) | |
| Forbidden. | |
| SharedFile & | operator= (const SharedFile &) |
| Forbidden. | |
| void | onPartEvent (PartData *pd, int evt) |
| Event handler for PartData events. | |
| void | onMoveEvent (MoveWorkPtr ptr, int evt) |
| Event handler for file moving events. | |
| void | checkFileSize (MetaData *md) |
| Verifies our current m_fileSize against what is stored in MetaData. | |
| void | onHashEvent (boost::shared_ptr< HashWork > hw, HashEvent evt) |
| Event handler for hash events. | |
| void | updateModDate () |
| Updates the files modification date that is stored in MetaDb. | |
| bool | isDuplicate () |
| Check if there are any other SharedFiles which match the specs of this file. | |
| void | setLocation (const boost::filesystem::path &loc) |
| Change the location for this file. | |
| void | addLocation (const boost::filesystem::path &loc) |
| Add an alternative location. | |
Static Private Member Functions | |
| static MetaData * | findMetaData (boost::filesystem::path loc, const std::string &name, PartData *pd=0) |
| Locate MetaData for a file. | |
Private Attributes | |
| boost::filesystem::path | m_location |
| (primary) Physical location | |
| MetaData * | m_metaData |
| May be null. | |
| PartData * | m_partData |
| May be null. | |
| uint64_t | m_uploaded |
| Amount uploaded. | |
| uint64_t | m_size |
| Size of file. | |
| boost::weak_ptr< HashWork > | m_pendingJob |
| Pending job (if any). | |
| boost::signals::connection | m_pdSigHandler |
| If we have PartData, this is connected to PartData events. | |
| std::vector< std::pair< uint32_t, boost::filesystem::path > > | m_locations |
| Vector of alternative locations, with timestamps. | |
Friends | |
| class | FilesList |
| std::ostream & | operator<< (std::ostream &o, const SharedFile &sf) |
|
||||||||||||
|
Construct SharedFile object.
Definition at line 110 of file sharedfile.cpp. References getName(), logTrace(), m_metaData, m_size, Object::setName(), SF_ADDED, SF_METADATA_ADDED, TRACE_SHAREDFILE, and verify(). |
Here is the call graph for this function:

|
||||||||||||
|
Construct SharedFile from existing PartData.
Definition at line 156 of file sharedfile.cpp. References CHECK_THROW, PartData::deleteFiles(), PartData::getMetaData(), getName(), isDuplicate(), m_metaData, m_partData, m_size, PartData::setMetaData(), Object::setName(), setPartData(), SF_ADDED, and verify(). |
Here is the call graph for this function:

|
|
Allowed by FilesList.
Definition at line 212 of file sharedfile.cpp. References m_partData, and m_pendingJob. |
|
|
Forbidden.
|
|
|
Forbidden.
|
|
|
Add an alternative location.
Definition at line 534 of file sharedfile.cpp. References m_locations. Referenced by isDuplicate(). |
|
|
Definition at line 91 of file sharedfile.h. |
|
|
Verifies our current m_fileSize against what is stored in MetaData.
Definition at line 197 of file sharedfile.cpp. References CHECK_THROW, getSize(), logWarning(), and MetaData::setFileSize(). Referenced by verify(). |
Here is the call graph for this function:

|
||||||||||||
|
|
|
|
Schedule for destruction.
Definition at line 340 of file sharedfile.cpp. References PartData::destroy(), m_partData, m_pdSigHandler, and SF_DESTROY. Referenced by isDuplicate(), onHashEvent(), onPartEvent(), and read(). |
Here is the call graph for this function:

|
||||||||||||||||
|
Locate MetaData for a file.
Definition at line 226 of file sharedfile.cpp. References MetaDb::find(), Utils::getFileSize(), Utils::getModDate(), MetaDb::instance(), logTrace(), and TRACE_SHAREDFILE. Referenced by verify(). |
Here is the call graph for this function:

|
|
Definition at line 73 of file sharedfile.h. Referenced by verify(). |
|
|
Definition at line 78 of file sharedfile.h. Referenced by FilesList::loadTempFile(). |
|
|
Retrieve the name of this object.
Reimplemented from Object. Definition at line 506 of file sharedfile.cpp. References PartData::getDestination(), m_location, and m_partData. Referenced by isDuplicate(), onMoveEvent(), read(), SharedFile(), and verify(). |
Here is the call graph for this function:

|
|
Definition at line 79 of file sharedfile.h. Referenced by isDuplicate(). |
|
|
Definition at line 77 of file sharedfile.h. Referenced by read(). |
|
|
Definition at line 81 of file sharedfile.h. Referenced by checkFileSize(). |
|
|
Definition at line 80 of file sharedfile.h. |
|
|
Definition at line 82 of file sharedfile.h. |
|
|
Definition at line 524 of file sharedfile.cpp. References m_partData. |
|
|
Check if there are any other SharedFiles which match the specs of this file.
Definition at line 407 of file sharedfile.cpp. References addLocation(), CHECK_THROW, destroy(), PartData::destroy(), MetaDb::findSharedFile(), HashSetBase::getFileHash(), MetaData::getHashSet(), getName(), getPartData(), MetaDb::instance(), isPartial(), logMsg(), m_location, m_metaData, setLocation(), and setMetaData(). Referenced by onHashEvent(), and SharedFile(). |
Here is the call graph for this function:

|
|
Definition at line 521 of file sharedfile.cpp. References m_partData. Referenced by isDuplicate(), and read(). |
|
||||||||||||
|
Event handler for hash events.
Definition at line 380 of file sharedfile.cpp. References CHECK_THROW, destroy(), HASH_FATAL_ERROR, MetaDb::instance(), isDuplicate(), logDebug(), logError(), m_metaData, MetaDb::push(), and SF_METADATA_ADDED. Referenced by verify(). |
Here is the call graph for this function:

|
||||||||||||
|
Event handler for file moving events.
Definition at line 311 of file sharedfile.cpp. References COL_BBLUE, COL_BYELLOW, COL_NONE, PartData::deleteFiles(), PartData::destroy(), getName(), logMsg(), m_partData, and setLocation(). Referenced by onPartEvent(). |
Here is the call graph for this function:

|
||||||||||||
|
Event handler for PartData events. Optimize this: Don't call second thread when src and dest are on same partition. Definition at line 281 of file sharedfile.cpp. References CHECK_THROW, destroy(), WorkThread::instance(), PartData::isComplete(), logDebug(), m_partData, m_pdSigHandler, onMoveEvent(), PD_COMPLETE, PD_DATA_FLUSHED, PD_DESTROY, WorkThread::postWork(), and updateModDate(). Referenced by setPartData(). |
Here is the call graph for this function:

|
|
Forbidden.
|
|
||||||||||||
|
Read data from disk from location and return it.
Definition at line 455 of file sharedfile.cpp. References CHECK_THROW, destroy(), MetaData::getModDate(), Utils::getModDate(), getName(), getPath(), PartData::isComplete(), isPartial(), m_location, m_locations, m_metaData, m_partData, O_BINARY, and setLocation(). |
Here is the call graph for this function:

|
|
Change the location for this file.
Definition at line 538 of file sharedfile.cpp. References m_location, m_metaData, and MetaData::setModDate(). Referenced by isDuplicate(), onMoveEvent(), and read(). |
Here is the call graph for this function:

|
|
Definition at line 529 of file sharedfile.cpp. References CHECK_THROW, and m_metaData. Referenced by isDuplicate(). |
|
|
Definition at line 325 of file sharedfile.cpp. References CHECK_THROW, PartData::getLocation(), m_location, m_partData, m_pdSigHandler, and onPartEvent(). Referenced by SharedFile(). |
Here is the call graph for this function:

|
|
Updates the files modification date that is stored in MetaDb.
Definition at line 514 of file sharedfile.cpp. References logTrace(), m_location, m_metaData, MetaData::setModDate(), and TRACE_SHAREDFILE. Referenced by onPartEvent(). |
Here is the call graph for this function:

|
|
Order the SharedFile to re-check the integrity of the physical file, and up2date metadata.
Definition at line 354 of file sharedfile.cpp. References checkFileSize(), findMetaData(), getLocation(), getName(), MetaDb::instance(), WorkThread::instance(), logTrace(), m_location, m_metaData, m_partData, m_pendingJob, onHashEvent(), WorkThread::postWork(), MetaDb::push(), and TRACE_SHAREDFILE. Referenced by SharedFile(). |
Here is the call graph for this function:

|
|
Definition at line 110 of file sharedfile.h. |
|
||||||||||||
|
Definition at line 348 of file sharedfile.cpp. |
|
|
(primary) Physical location
Definition at line 188 of file sharedfile.h. Referenced by getName(), isDuplicate(), read(), setLocation(), setPartData(), updateModDate(), and verify(). |
|
|
Vector of alternative locations, with timestamps.
Definition at line 200 of file sharedfile.h. Referenced by addLocation(), and read(). |
|
|
May be null.
Definition at line 189 of file sharedfile.h. Referenced by isDuplicate(), onHashEvent(), read(), setLocation(), setMetaData(), SharedFile(), updateModDate(), and verify(). |
|
|
May be null.
Definition at line 190 of file sharedfile.h. Referenced by destroy(), getName(), isComplete(), isPartial(), onMoveEvent(), onPartEvent(), read(), setPartData(), SharedFile(), verify(), and ~SharedFile(). |
|
|
If we have PartData, this is connected to PartData events.
Definition at line 197 of file sharedfile.h. Referenced by destroy(), onPartEvent(), and setPartData(). |
|
|
Pending job (if any).
Definition at line 194 of file sharedfile.h. Referenced by verify(), and ~SharedFile(). |
|
|
Size of file.
Definition at line 192 of file sharedfile.h. Referenced by SharedFile(). |
|
|
Amount uploaded.
Definition at line 191 of file sharedfile.h. |