From 274f924ca01674ef9a8c3220cd91025cd4295ba1 Mon Sep 17 00:00:00 2001 From: mr-alice Date: Mon, 12 Sep 2016 20:55:20 +0200 Subject: [PATCH] fixed getFileInfo and transfer from new database --- .../src/file_sharing/dir_hierarchy.cc | 4 +++ .../src/file_sharing/directory_storage.cc | 31 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/file_sharing/dir_hierarchy.cc b/libretroshare/src/file_sharing/dir_hierarchy.cc index 0ad931077..d58d91170 100644 --- a/libretroshare/src/file_sharing/dir_hierarchy.cc +++ b/libretroshare/src/file_sharing/dir_hierarchy.cc @@ -260,6 +260,7 @@ bool InternalFileHierarchyStorage::updateHash(const DirectoryStorage::EntryIndex std::cerr << "[directory storage] updating hash at index " << file_index << ", hash=" << hash << std::endl; RsFileHash& old_hash (static_cast(mNodes[file_index])->file_hash) ; + mFileHashes[hash] = file_index ; old_hash = hash ; @@ -282,6 +283,9 @@ bool InternalFileHierarchyStorage::updateFile(const DirectoryStorage::EntryIndex fe.file_modtime = modf_time; fe.file_name = fname; + if(!hash.isNull()) + mFileHashes[hash] = file_index ; + return true; } diff --git a/libretroshare/src/file_sharing/directory_storage.cc b/libretroshare/src/file_sharing/directory_storage.cc index 933660986..779a2c04d 100644 --- a/libretroshare/src/file_sharing/directory_storage.cc +++ b/libretroshare/src/file_sharing/directory_storage.cc @@ -185,9 +185,36 @@ void DirectoryStorage::print() bool LocalDirectoryStorage::getFileInfo(DirectoryStorage::EntryIndex i,FileInfo& info) { - RS_STACK_MUTEX(mDirStorageMtx) ; + DirDetails d; + extractData(i,d) ; + + info.storage_permission_flags = d.flags; // Combination of the four RS_DIR_FLAGS_*. Updated when the file is a local stored file. + info.parent_groups = d.parent_groups; + info.transfer_info_flags = TransferRequestFlags(); // various flags from RS_FILE_HINTS_* + info.path = d.path + "/" + d.name; + info.fname = d.name; + info.hash = d.hash; + info.size = d.count; + + // all this stuff below is not useful in this case. + + info.mId = 0; /* (GUI) Model Id -> unique number */ + info.ext.clear(); + info.avail = 0; /* how much we have */ + info.rank = 0; + info.age = 0; + info.queue_position =0; + info.searchId = 0; /* 0 if none */ + + /* Transfer Stuff */ + info.transfered = 0; + info.tfRate = 0; /* in kbytes */ + info.downloadStatus = FT_STATE_COMPLETE ; + std::list peers; + + info.priority = SPEED_NORMAL; + info.lastTS = 0; - NOT_IMPLEMENTED(); return true; }