Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 42 additions & 11 deletions src/ft/ftextralist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <retroshare/rsfiles.h>
#include "ft/ftextralist.h"
#include "rsitems/rsconfigitems.h"
#include "util/rsdebug.h"
#include "util/rsdir.h"
#include "util/rstime.h"
#include <stdio.h>
Expand Down Expand Up @@ -99,20 +100,50 @@ void ftExtraList::hashAFile()
details.info.path, details.info.fname, details.info.hash,
details.info.size ))
{
RS_STACK_MUTEX(extMutex);
{
RS_STACK_MUTEX(extMutex);

/* stick it in the available queue */
mFiles[details.info.hash] = details;
mHashOfHash[makeEncryptedHash(details.info.hash)] = details.info.hash;
/* stick it in the available queue */
mFiles[details.info.hash] = details;
mHashOfHash[makeEncryptedHash(details.info.hash)] = details.info.hash;

/* add to the path->hash map */
mHashedList[details.info.path] = details.info.hash;

IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW);
/* add to the path->hash map */
mHashedList[details.info.path] = details.info.hash;

IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW);
}

auto ev = std::make_shared<RsSharedDirectoriesEvent>();
ev->mEventCode = RsSharedDirectoriesEventCode::EXTRA_LIST_FILE_ADDED;
rsEvents->postEvent(ev);
if(rsEvents)
{
auto ev = std::make_shared<RsSharedDirectoriesEvent>();
ev->mEventCode = RsSharedDirectoriesEventCode::EXTRA_LIST_FILE_ADDED;
ev->mFilePath = details.info.path;
ev->mFileHash = details.info.hash;
rsEvents->postEvent(ev);
}
}
else
{
/* hashExtraFile() has already refused the paths that do not exist and
* the directories, so reaching here means the file was there and could
* still not be read: permissions, a share unmounted or a file renamed
* between the two, an I/O error, or this thread being stopped.
*
* Failing silently leaves every caller waiting for a hash that will
* never come -- the file never enters mHashedList, so ExtraFileStatus()
* keeps answering "not ready" forever, and the web UI attach dialog
* polls it once a second for the rest of the session. */
RsErr() << __PRETTY_FUNCTION__ << " failed to hash " << details.info.path
<< ", it will not be added to the extra list" << std::endl;

if(rsEvents)
{
auto ev = std::make_shared<RsSharedDirectoriesEvent>();
ev->mEventCode =
RsSharedDirectoriesEventCode::EXTRA_LIST_FILE_HASH_FAILED;
ev->mFilePath = details.info.path;
rsEvents->postEvent(ev);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/retroshare/rsfiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ enum class RsSharedDirectoriesEventCode: uint8_t {
FRIEND_DIR_LIST_UPDATED = 0x0b, // NOTIFY_LIST_DIRLIST_FRIENDS, friend dir list has been updated
OWN_DIR_LIST_UPDATED = 0x0c, // NOTIFY_LIST_DIRLIST_LOCAL , own dir list has been updated
OWN_DIR_LIST_PROCESSING = 0x0d, // NOTIFY_LIST_DIRLIST_LOCAL prechange
EXTRA_LIST_FILE_HASH_FAILED = 0x0e, // mFilePath: file that could not be hashed, mFileHash null
};

enum class RsFileTransferEventCode: uint8_t {
Expand Down
Loading