From 16231dea2b1a00a62b2f05e4c60933a39baf57ed Mon Sep 17 00:00:00 2001 From: joss17 Date: Tue, 5 May 2009 13:32:59 +0000 Subject: [PATCH] Merge branch 'singleFileClient' git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1167 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/dbase/fimonitor.cc | 14 ++++++++++++-- libretroshare/src/dbase/findex.cc | 7 +++++++ libretroshare/src/dbase/fistore.cc | 14 +++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/dbase/fimonitor.cc b/libretroshare/src/dbase/fimonitor.cc index 972824b11..4ae923a8d 100644 --- a/libretroshare/src/dbase/fimonitor.cc +++ b/libretroshare/src/dbase/fimonitor.cc @@ -96,7 +96,11 @@ bool FileIndexMonitor::findLocalFile(std::string hash, size = fe->size; ok = true; - } + } else { + fullpath = fe->name; + size = fe->size; + ok = true; + } #ifdef FIM_DEBUG std::cerr << "FileIndexMonitor::findLocalFile() Found Path: " << fullpath << std::endl; std::cerr << "FileIndexMonitor::findLocalFile() Found Size: " << size << std::endl; @@ -132,7 +136,13 @@ bool FileIndexMonitor::convertSharedFilePath(std::string path, std::string &f std::cerr << "FileIndexMonitor::convertSharedFilePath() Found Path: " << fullpath << std::endl; #endif ok = true; - } + } else { + fullpath = path; + ok = true; + #ifdef FIM_DEBUG + std::cerr << "FileIndexMonitor::convertSharedFilePath() Found Path: " << fullpath << std::endl; +#endif + } } fiMutex.unlock(); /* UNLOCKED DIRS */ diff --git a/libretroshare/src/dbase/findex.cc b/libretroshare/src/dbase/findex.cc index 6f526b3c7..dee26b288 100644 --- a/libretroshare/src/dbase/findex.cc +++ b/libretroshare/src/dbase/findex.cc @@ -757,6 +757,13 @@ int FileIndex::loadIndex(std::string filename, std::string expectedHash, uint64_ (it->second)->parent = root; } + std::map::iterator it2; + for(it2 = root->files.begin(); + it2 != root->files.end(); it2++) + { + (it2->second)->parent = root; + } + break; } /* pop stack */ diff --git a/libretroshare/src/dbase/fistore.cc b/libretroshare/src/dbase/fistore.cc index 02896c5ab..9a5e9a5cd 100644 --- a/libretroshare/src/dbase/fistore.cc +++ b/libretroshare/src/dbase/fistore.cc @@ -336,7 +336,19 @@ int FileIndexStore::RequestDirDetails(void *ref, DirDetails &details, uint32_t f else { /* NEW add path (to dir - if dir, or parent dir - if file? */ - details.path = parent->path; + if (NULL != (person = dynamic_cast(parent))) { + //if parent if root, then the path is inside the name; we should parse the name for the last / char + int i; + for(i = details.name.length(); (i > 0) && (details.name[i] != '/'); i--); + if (i != 0) { + //the file is in a subdir, let's remove the / char and set correct path + details.path = details.name.substr(0,i); + details.name = details.name.substr(i + 1); + } + + } else { + details.path = parent->path; + } while(parent->parent) parent = parent->parent;