mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed core dump in printout of empty slots. Improved dir sync-ing strategy
This commit is contained in:
parent
e985a2c927
commit
ddc89a6535
@ -466,6 +466,8 @@ bool InternalFileHierarchyStorage::updateDirEntry(const DirectoryStorage::EntryI
|
||||
uint32_t n=0;
|
||||
for(uint32_t i=0;i<d.subdirs.size();++i)
|
||||
{
|
||||
static_cast<DirEntry*>(mNodes[d.subdirs[i]])->dir_update_time = 0 ; // force the update of the subdir.
|
||||
|
||||
mNodes[d.subdirs[i]]->parent_index = indx ;
|
||||
mNodes[d.subdirs[i]]->row = n++ ;
|
||||
}
|
||||
@ -767,10 +769,11 @@ void InternalFileHierarchyStorage::recursPrint(int depth,DirectoryStorage::Entry
|
||||
recursPrint(depth+1,d.subdirs[i]) ;
|
||||
|
||||
for(uint32_t i=0;i<d.subfiles.size();++i)
|
||||
{
|
||||
FileEntry& f(*static_cast<FileEntry*>(mNodes[d.subfiles[i]]));
|
||||
std::cerr << indent << " hash:" << f.file_hash << " ts:" << (uint64_t)f.file_modtime << " " << f.file_size << " " << f.file_name << ", parent: " << f.parent_index << ", row: " << f.row << std::endl;
|
||||
}
|
||||
if(mNodes[d.subfiles[i]] != NULL)
|
||||
{
|
||||
FileEntry& f(*static_cast<FileEntry*>(mNodes[d.subfiles[i]]));
|
||||
std::cerr << indent << " hash:" << f.file_hash << " ts:" << (uint64_t)f.file_modtime << " " << f.file_size << " " << f.file_name << ", parent: " << f.parent_index << ", row: " << f.row << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
bool InternalFileHierarchyStorage::nodeAccessError(const std::string& s)
|
||||
|
@ -930,9 +930,23 @@ bool p3FileDatabase::convertSharedFilePath(const std::string& path,std::string&
|
||||
// - the max time is computed upward until the root of the hierarchy
|
||||
// - because the hash is performed late, the last modf time upward is updated only when the hash is obtained.
|
||||
//
|
||||
// Remote dirs store the last modif time of the files/dir in the friend's time
|
||||
// - local node sends the last known modf time to friends,
|
||||
// - friends respond with either a full directory content, or an acknowledge that the time is right
|
||||
// Remote dirs store
|
||||
// 1 - recursive modif time of the files/dir in the friend's time
|
||||
// 2 - update TS in the local time
|
||||
//
|
||||
// The update algorithm is the following:
|
||||
//
|
||||
// [Client side]
|
||||
// - every 30 sec, send a sync packet for the root of the hierarchy containing the remote known max recurs TS.
|
||||
// - crawl through all directories and if the update TS is 0, ask for sync too.
|
||||
// - when a sync respnse is received:
|
||||
// - if response is ACK, set the update time to now. Nothing changed.
|
||||
// - if response is an update
|
||||
// * locally update the subfiles
|
||||
// * for all subdirs, set the local update time to 0 (so as to force a sync)
|
||||
//
|
||||
// [Server side]
|
||||
// - when sync req is received, compare to local recurs TS, and send ACK or full update accordingly
|
||||
//
|
||||
// Directories are designated by their hash, instead of their index. This allows to hide the non shared directories
|
||||
// behind a layer of abstraction, at the cost of a logarithmic search, which is acceptable as far as dir sync-ing between
|
||||
@ -1004,7 +1018,7 @@ void p3FileDatabase::handleDirSyncRequest(RsFileListsSyncRequestItem *item)
|
||||
time_t local_recurs_max_time,local_update_time;
|
||||
mLocalSharedDirs->getDirUpdateTS(entry_index,local_recurs_max_time,local_update_time);
|
||||
|
||||
if(item->last_known_recurs_modf_TS < local_recurs_max_time)
|
||||
if(item->last_known_recurs_modf_TS != local_recurs_max_time) // normally, should be "<", but since we provided the TS it should be equal, so != is more robust.
|
||||
{
|
||||
P3FILELISTS_DEBUG() << " Directory is more recent than what the friend knows. Sending full dir content as response." << std::endl;
|
||||
|
||||
@ -1129,16 +1143,10 @@ void p3FileDatabase::locked_recursSweepRemoteDirectory(RemoteDirectoryStorage *r
|
||||
|
||||
// compare TS
|
||||
|
||||
if(now > local_update_TS + DELAY_BETWEEN_REMOTE_DIRECTORY_SYNC_REQ) // we need to compare local times only. We cannot compare local (now) with remote time.
|
||||
{
|
||||
if((e == 0 && now > local_update_TS + DELAY_BETWEEN_REMOTE_DIRECTORY_SYNC_REQ) || local_update_TS == 0) // we need to compare local times only. We cannot compare local (now) with remote time.
|
||||
if(generateAndSendSyncRequest(rds,e,recurs_max_modf_TS_remote_time))
|
||||
P3FILELISTS_DEBUG() << " Asking for sync of directory " << e << " to peer " << rds->peerId() << " because it's " << (now - local_update_TS) << " secs old since last check." << std::endl;
|
||||
|
||||
// Dont recurs into sub-directories, since we dont know yet were to go.
|
||||
|
||||
//return ;
|
||||
}
|
||||
|
||||
for(DirectoryStorage::DirIterator it(rds,e);it;++it)
|
||||
locked_recursSweepRemoteDirectory(rds,*it,depth+1);
|
||||
}
|
||||
|
@ -163,10 +163,10 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD
|
||||
QHeaderView * header = ui.dirTreeView->header () ;
|
||||
|
||||
header->resizeSection ( COLUMN_NAME, 490 );
|
||||
header->resizeSection ( COLUMN_SIZE, 70 );
|
||||
header->resizeSection ( COLUMN_AGE, 100 );
|
||||
header->resizeSection ( COLUMN_FRIEND, 100 );
|
||||
header->resizeSection ( COLUMN_DIR, 100 );
|
||||
header->resizeSection ( COLUMN_SIZE, 70 );
|
||||
header->resizeSection ( COLUMN_AGE, 100 );
|
||||
header->resizeSection ( COLUMN_FRIEND,100);
|
||||
header->resizeSection ( COLUMN_DIR, 100 );
|
||||
|
||||
header->setStretchLastSection(false);
|
||||
|
||||
@ -869,6 +869,10 @@ void SharedFilesDialog::restoreExpandedPaths(const std::set<std::string>& expand
|
||||
if(ui.dirTreeView->model() == NULL)
|
||||
return ;
|
||||
|
||||
// we need to disable this, because the signal will trigger unnecessary update at the friend.
|
||||
|
||||
ui.dirTreeView->blockSignals(true) ;
|
||||
|
||||
#ifdef DEBUG_SHARED_FILES_DIALOG
|
||||
std::cerr << "Restoring expanded items. " << std::endl;
|
||||
#endif
|
||||
@ -877,6 +881,7 @@ void SharedFilesDialog::restoreExpandedPaths(const std::set<std::string>& expand
|
||||
std::string path = ui.dirTreeView->model()->index(row,0).data(Qt::DisplayRole).toString().toStdString();
|
||||
recursRestoreExpandedItems(ui.dirTreeView->model()->index(row,0),path,expanded_indexes);
|
||||
}
|
||||
ui.dirTreeView->blockSignals(false) ;
|
||||
}
|
||||
|
||||
void SharedFilesDialog::recursSaveExpandedItems(const QModelIndex& index,const std::string& path,std::set<std::string>& exp)
|
||||
|
Loading…
Reference in New Issue
Block a user