void Client::on(DirectoryListingManagerListener::OpenListing, const DirectoryListingPtr& aList, const string& aDir, const string& aXML) noexcept { if (aList->getPartialList()) { aList->addPartialListTask(aXML, aDir, false); } else { aList->addFullListTask(aDir); } }
json FilelistApi::serializeList(const DirectoryListingPtr& aList) noexcept { int64_t totalSize = -1; size_t totalFiles = -1; aList->getPartialListInfo(totalSize, totalFiles); return{ { "id", aList->getUser()->getCID().toBase32() }, { "user", Serializer::serializeHintedUser(aList->getHintedUser()) }, { "state", FilelistInfo::serializeState(aList) }, { "location", FilelistInfo::serializeLocation(aList) }, { "partial", aList->getPartialList() }, { "total_files", totalFiles }, { "total_size", totalSize }, { "read", aList->isRead() }, { "share_profile", aList->getIsOwnList() ? Serializer::serializeShareProfileSimple(aList->getShareProfile()) : json() }, }; }
bool DirectoryListingManager::download(const DirectoryDownloadInfo::Ptr& di, const DirectoryListingPtr& aList, const string& aTarget, bool aHasFreeSpace) noexcept { auto getList = [&] { addDirectoryDownload(di->getListPath(), di->getBundleName(), aList->getHintedUser(), di->getTarget(), di->getTargetType(), di->getSizeUnknown(), di->getPriority(), di->getRecursiveListAttempted() ? true : false, di->getAutoSearch(), false, false); }; auto dir = aList->findDirectory(di->getListPath()); if (!dir) { // Downloading directory for an open list? But don't queue anything if it's a fresh list and the directory is missing. if (aList->getisClientView()) { getList(); } return false; } if (aList->getPartialList() && dir->findIncomplete()) { // Non-recursive partial list getList(); return false; } // Queue the directory return aList->downloadDirImpl(dir, aTarget + di->getBundleName() + PATH_SEPARATOR, aHasFreeSpace ? di->getPriority() : QueueItemBase::PAUSED_FORCE, di->getAutoSearch()); }