Commit 8f75bc24 authored by Paweł Wegner's avatar Paweł Wegner

Replace std::vector<IItem::Pointer> with IItem::List.

parent b686c620
......@@ -140,7 +140,7 @@ void CloudContext::loadCachedDirectories() {
QJsonObject json = QJsonDocument::fromBinaryData(file.readAll()).object();
for (auto directory : json["directory"].toArray()) {
auto json = directory.toObject();
std::vector<IItem::Pointer> items;
IItem::List items;
for (auto item : json["list"].toArray()) {
try {
items.push_back(IItem::fromString(item.toString().toStdString()));
......@@ -327,7 +327,7 @@ void CloudContext::add(std::shared_ptr<ICloudProvider> p,
}
void CloudContext::cacheDirectory(ListDirectoryCacheKey directory,
const std::vector<IItem::Pointer>& lst) {
const IItem::List& lst) {
{
std::lock_guard<std::mutex> lock(mutex_);
std::vector<std::string> data;
......@@ -339,8 +339,7 @@ void CloudContext::cacheDirectory(ListDirectoryCacheKey directory,
});
}
std::vector<IItem::Pointer> CloudContext::cachedDirectory(
ListDirectoryCacheKey key) {
IItem::List CloudContext::cachedDirectory(ListDirectoryCacheKey key) {
std::lock_guard<std::mutex> lock(mutex_);
auto it = list_directory_cache_.find(key);
if (it == std::end(list_directory_cache_))
......
......@@ -86,8 +86,7 @@ class CloudContext : public QObject {
void cacheDirectory(ListDirectoryCacheKey directory,
const std::vector<cloudstorage::IItem::Pointer>&);
std::vector<cloudstorage::IItem::Pointer> cachedDirectory(
ListDirectoryCacheKey);
cloudstorage::IItem::List cachedDirectory(ListDirectoryCacheKey);
void schedule(std::function<void()>);
signals:
......
......@@ -15,7 +15,7 @@ class ListDirectory : public IListDirectoryCallback {
notifier_->addedItem(item);
}
void done(EitherError<std::vector<IItem::Pointer>> r) override {
void done(EitherError<IItem::List> r) override {
emit notifier_->finishedList(r);
notifier_->deleteLater();
}
......@@ -62,7 +62,7 @@ void ListDirectoryModel::remove(int idx) {
endRemoveRows();
}
void ListDirectoryModel::match(const std::vector<IItem::Pointer>& lst) {
void ListDirectoryModel::match(const IItem::List& lst) {
std::unordered_set<std::string> id;
for (size_t i = lst.size(); i-- > 0;) {
auto idx = find(lst[i]);
......@@ -120,14 +120,14 @@ void ListDirectoryRequest::update(CloudContext* context, CloudItem* item) {
description);
});
connect(this, &ListDirectoryRequest::finished, context,
[=](ListDirectoryCacheKey key, const std::vector<IItem::Pointer>& r) {
[=](ListDirectoryCacheKey key, const IItem::List& r) {
context->cacheDirectory(key, r);
});
auto object = new RequestNotifier;
auto provider = item->provider().variant();
connect(object, &RequestNotifier::finishedList, this,
[=](EitherError<std::vector<IItem::Pointer>> r) {
[=](EitherError<IItem::List> r) {
set_done(true);
if (r.left())
return errorOccurred(provider, r.left()->code_,
......
......@@ -75,7 +75,7 @@ int main(int, char**) {
std::string command_line;
ICloudProvider::Pointer current_provider;
IItem::Pointer current_directory;
std::vector<IItem::Pointer> directory_stack;
IItem::List directory_stack;
std::string prompt = "/";
while (std::cout << prompt << ": " && std::getline(std::cin, command_line)) {
std::stringstream line(command_line);
......
......@@ -367,7 +367,7 @@ IHttpRequest::Pointer AmazonS3::downloadFileRequest(const IItem& item,
return http()->create(endpoint() + "/" + escapePath(item.id()), "GET");
}
std::vector<IItem::Pointer> AmazonS3::listDirectoryResponse(
IItem::List AmazonS3::listDirectoryResponse(
const IItem& parent, std::istream& stream,
std::string& next_page_token) const {
std::stringstream sstream;
......@@ -376,7 +376,7 @@ std::vector<IItem::Pointer> AmazonS3::listDirectoryResponse(
if (document.Parse(sstream.str().c_str(), sstream.str().size()) !=
tinyxml2::XML_SUCCESS)
throw std::logic_error("invalid xml");
std::vector<IItem::Pointer> result;
IItem::List result;
if (auto name_element = document.RootElement()->FirstChildElement("Name")) {
std::string bucket = name_element->GetText();
for (auto child = document.RootElement()->FirstChildElement("Contents");
......
......@@ -74,7 +74,7 @@ class AmazonS3 : public CloudProvider {
IHttpRequest::Pointer downloadFileRequest(
const IItem&, std::ostream& input_stream) const override;
std::vector<IItem::Pointer> listDirectoryResponse(
IItem::List listDirectoryResponse(
const IItem&, std::istream&, std::string& next_page_token) const override;
IItem::Pointer createDirectoryResponse(const IItem& parent,
const std::string& name,
......
......@@ -200,10 +200,10 @@ IItem::Pointer Box::getItemDataResponse(std::istream& stream) const {
return toItem(util::json::from_stream(stream));
}
std::vector<IItem::Pointer> Box::listDirectoryResponse(
const IItem&, std::istream& stream, std::string& next_page_token) const {
IItem::List Box::listDirectoryResponse(const IItem&, std::istream& stream,
std::string& next_page_token) const {
auto response = util::json::from_stream(stream);
std::vector<IItem::Pointer> result;
IItem::List result;
for (const Json::Value& v : response["entries"]) result.push_back(toItem(v));
int offset = response["offset"].asInt();
int limit = response["limit"].asInt();
......
......@@ -66,7 +66,7 @@ class Box : public CloudProvider {
IHttpRequest::Pointer getGeneralDataRequest(std::ostream&) const override;
IItem::Pointer getItemDataResponse(std::istream& response) const override;
std::vector<IItem::Pointer> listDirectoryResponse(
IItem::List listDirectoryResponse(
const IItem&, std::istream&, std::string& next_page_token) const override;
std::string getItemUrlResponse(const IItem& item,
const IHttpRequest::HeaderParameters&,
......
......@@ -619,8 +619,8 @@ std::string CloudProvider::getItemUrlResponse(
return std::static_pointer_cast<Item>(getItemDataResponse(stream))->url();
}
std::vector<IItem::Pointer> CloudProvider::listDirectoryResponse(
const IItem&, std::istream&, std::string&) const {
IItem::List CloudProvider::listDirectoryResponse(const IItem&, std::istream&,
std::string&) const {
return {};
}
......
......@@ -231,9 +231,9 @@ class CloudProvider : public ICloudProvider,
*
* @return item set
*/
virtual std::vector<IItem::Pointer> listDirectoryResponse(
const IItem& directory, std::istream& response,
std::string& next_page_token) const;
virtual IItem::List listDirectoryResponse(const IItem& directory,
std::istream& response,
std::string& next_page_token) const;
virtual IItem::Pointer renameItemResponse(const IItem& old_item,
const std::string& name,
......
......@@ -291,10 +291,10 @@ IHttpRequest::Pointer Dropbox::renameItemRequest(const IItem& item,
return request;
}
std::vector<IItem::Pointer> Dropbox::listDirectoryResponse(
const IItem&, std::istream& stream, std::string& next_page_token) const {
IItem::List Dropbox::listDirectoryResponse(const IItem&, std::istream& stream,
std::string& next_page_token) const {
auto response = util::json::from_stream(stream);
std::vector<IItem::Pointer> result;
IItem::List result;
for (const Json::Value& v : response["entries"]) result.push_back(toItem(v));
if (response["has_more"].asBool()) {
next_page_token = response["cursor"].asString();
......
......@@ -66,7 +66,7 @@ class Dropbox : public CloudProvider {
const std::string& name,
std::ostream&) const override;
std::vector<IItem::Pointer> listDirectoryResponse(
IItem::List listDirectoryResponse(
const IItem&, std::istream&, std::string& next_page_token) const override;
std::string getItemUrlResponse(const IItem& item,
const IHttpRequest::HeaderParameters&,
......
......@@ -293,11 +293,11 @@ IItem::Pointer GoogleDrive::getItemDataResponse(std::istream& response) const {
return toItem(util::json::from_stream(response));
}
std::vector<IItem::Pointer> GoogleDrive::listDirectoryResponse(
IItem::List GoogleDrive::listDirectoryResponse(
const IItem& item, std::istream& stream,
std::string& next_page_token) const {
auto response = util::json::from_stream(stream);
std::vector<IItem::Pointer> result;
IItem::List result;
for (Json::Value v : response["files"]) result.push_back(toItem(v));
if (item.id() == rootDirectory()->id())
result.push_back(util::make_unique<Item>(
......
......@@ -71,7 +71,7 @@ class GoogleDrive : public CloudProvider {
std::string getItemUrlResponse(const IItem& item,
const IHttpRequest::HeaderParameters&,
std::istream& response) const override;
std::vector<IItem::Pointer> listDirectoryResponse(
IItem::List listDirectoryResponse(
const IItem&, std::istream&, std::string& next_page_token) const override;
GeneralData getGeneralDataResponse(std::istream& response) const override;
......
......@@ -153,15 +153,16 @@ IHttpRequest::Pointer GooglePhotos::uploadFileRequest(
return request;
}
std::vector<IItem::Pointer> GooglePhotos::listDirectoryResponse(
const IItem &, std::istream &stream, std::string &) const {
IItem::List GooglePhotos::listDirectoryResponse(const IItem &,
std::istream &stream,
std::string &) const {
std::stringstream sstream;
sstream << stream.rdbuf();
tinyxml2::XMLDocument document;
if (document.Parse(sstream.str().c_str(), sstream.str().size()) !=
tinyxml2::XML_SUCCESS)
throw std::logic_error("invalid xml");
std::vector<IItem::Pointer> result;
IItem::List result;
for (auto child = document.RootElement()->FirstChildElement("entry"); child;
child = child->NextSiblingElement("entry")) {
result.push_back(toItem(child));
......
......@@ -47,7 +47,7 @@ class GooglePhotos : public CloudProvider {
IHttpRequest::Pointer uploadFileRequest(
const IItem& directory, const std::string& filename,
std::ostream& prefix_stream, std::ostream& suffix_stream) const override;
std::vector<IItem::Pointer> listDirectoryResponse(
IItem::List listDirectoryResponse(
const IItem&, std::istream&, std::string& next_page_token) const override;
DownloadFileRequest::Pointer downloadFileAsync(IItem::Pointer,
IDownloadFileCallback::Pointer,
......
......@@ -317,10 +317,10 @@ IHttpRequest::Pointer HubiC::getItemUrlRequest(const IItem &item,
return r;
}
std::vector<IItem::Pointer> HubiC::listDirectoryResponse(
IItem::List HubiC::listDirectoryResponse(
const IItem &, std::istream &stream, std::string &next_page_token) const {
auto json = util::json::from_stream(stream);
std::vector<IItem::Pointer> result;
IItem::List result;
for (auto &&v : json)
if (!v.isMember("subdir")) {
result.push_back(toItem(v));
......
......@@ -75,7 +75,7 @@ class HubiC : public CloudProvider {
std::string getItemUrlResponse(const IItem& item,
const IHttpRequest::HeaderParameters&,
std::istream& response) const override;
std::vector<IItem::Pointer> listDirectoryResponse(
IItem::List listDirectoryResponse(
const IItem&, std::istream&, std::string& next_page_token) const override;
IItem::Pointer toItem(const Json::Value&) const;
......
......@@ -63,11 +63,11 @@ fs::path from_string(const std::string &string) {
return fs::path(string, std::codecvt_utf8<wchar_t>());
}
void list_directory(
const LocalDrive &p, IItem::Pointer item,
std::function<void(EitherError<std::vector<IItem::Pointer>>)> done,
std::function<void(IItem::Pointer)> received_item = [](IItem::Pointer) {}) {
std::vector<IItem::Pointer> vector;
void list_directory(const LocalDrive &p, IItem::Pointer item,
std::function<void(EitherError<IItem::List>)> done,
std::function<void(IItem::Pointer)> received_item =
[](IItem::Pointer) {}) {
IItem::List result;
error_code ec;
auto directory = fs::directory_iterator(p.path(item), ec);
if (ec) return done(Error{ec.value(), ec.message()});
......@@ -84,10 +84,10 @@ void list_directory(
to_string(e.path().filename()), to_string(e.path()), size, timestamp,
is_directory ? IItem::FileType::Directory : IItem::FileType::Unknown);
received_item(item);
vector.push_back(item);
result.push_back(item);
}
}
done(vector);
done(result);
}
} // namespace
......@@ -118,7 +118,7 @@ AuthorizeRequest::Pointer LocalDrive::authorizeAsync() {
LocalDrive::ListDirectoryRequest::Pointer LocalDrive::listDirectoryAsync(
IItem::Pointer item, IListDirectoryCallback::Pointer callback) {
using ItemList = EitherError<std::vector<IItem::Pointer>>;
using ItemList = EitherError<IItem::List>;
return request<ItemList>(
[=](ItemList e) { callback->done(e); },
[=](Request<ItemList>::Pointer r) {
......@@ -133,13 +133,12 @@ LocalDrive::listDirectoryPageAsync(IItem::Pointer item, const std::string &,
return request<EitherError<PageData>>(
[=](EitherError<PageData> e) { callback(e); },
[=](Request<EitherError<PageData>>::Pointer r) {
list_directory(*this, item,
[=](EitherError<std::vector<IItem::Pointer>> e) {
if (e.left())
r->done(e.left());
else
r->done(PageData{*e.right(), ""});
});
list_directory(*this, item, [=](EitherError<IItem::List> e) {
if (e.left())
r->done(e.left());
else
r->done(PageData{*e.right(), ""});
});
});
}
......
......@@ -563,13 +563,13 @@ ICloudProvider::GetItemDataRequest::Pointer MegaNz::getItemDataAsync(
ICloudProvider::ListDirectoryRequest::Pointer MegaNz::listDirectoryAsync(
IItem::Pointer item, IListDirectoryCallback::Pointer cb) {
using ItemList = EitherError<std::vector<IItem::Pointer>>;
using ItemList = EitherError<IItem::List>;
auto callback = cb.get();
auto resolver = [=](Request<ItemList>::Pointer r) {
ensureAuthorized<ItemList>(r, [=] {
auto node = this->node(item->id());
if (node) {
std::vector<IItem::Pointer> result;
IItem::List result;
std::unique_ptr<mega::MegaNodeList> lst(mega_->getChildren(node.get()));
if (lst) {
for (int i = 0; i < lst->size(); i++) {
......@@ -791,7 +791,7 @@ MegaNz::listDirectoryPageAsync(IItem::Pointer item, const std::string&,
ensureAuthorized<EitherError<PageData>>(r, [=] {
auto node = this->node(item->id());
if (node) {
std::vector<IItem::Pointer> result;
IItem::List result;
std::unique_ptr<mega::MegaNodeList> lst(mega_->getChildren(node.get()));
if (lst) {
for (int i = 0; i < lst->size(); i++) {
......
......@@ -239,9 +239,9 @@ IItem::Pointer OneDrive::toItem(const Json::Value& v) const {
return std::move(item);
}
std::vector<IItem::Pointer> OneDrive::listDirectoryResponse(
IItem::List OneDrive::listDirectoryResponse(
const IItem&, std::istream& stream, std::string& next_page_token) const {
std::vector<IItem::Pointer> result;
IItem::List result;
auto response = util::json::from_stream(stream);
for (Json::Value v : response["value"]) result.push_back(toItem(v));
if (response.isMember("@odata.nextLink"))
......
......@@ -63,8 +63,8 @@ class OneDrive : public CloudProvider {
IHttpRequest::Pointer renameItemRequest(const IItem&, const std::string& name,
std::ostream&) const override;
std::vector<IItem::Pointer> listDirectoryResponse(
const IItem&, std::istream&, std::string&) const override;
IItem::List listDirectoryResponse(const IItem&, std::istream&,
std::string&) const override;
IItem::Pointer getItemDataResponse(std::istream& response) const override;
private:
......
......@@ -200,10 +200,10 @@ IHttpRequest::Pointer PCloud::getGeneralDataRequest(std::ostream&) const {
return http()->create(endpoint() + "/userinfo");
}
std::vector<IItem::Pointer> PCloud::listDirectoryResponse(
const IItem&, std::istream& response, std::string&) const {
IItem::List PCloud::listDirectoryResponse(const IItem&, std::istream& response,
std::string&) const {
auto json = util::json::from_stream(response);
std::vector<IItem::Pointer> result;
IItem::List result;
for (auto&& v : json["metadata"]["contents"]) result.push_back(toItem(v));
return result;
}
......
......@@ -65,7 +65,7 @@ class PCloud : public CloudProvider {
std::ostream&) const override;
IHttpRequest::Pointer getGeneralDataRequest(std::ostream&) const override;
std::vector<IItem::Pointer> listDirectoryResponse(
IItem::List listDirectoryResponse(
const IItem&, std::istream&, std::string& next_page_token) const override;
std::string getItemUrlResponse(const IItem& item,
const IHttpRequest::HeaderParameters&,
......
......@@ -236,9 +236,8 @@ IItem::Pointer WebDav::moveItemResponse(const IItem& source, const IItem& dest,
return std::move(i);
}
std::vector<IItem::Pointer> WebDav::listDirectoryResponse(const IItem&,
std::istream& stream,
std::string&) const {
IItem::List WebDav::listDirectoryResponse(const IItem&, std::istream& stream,
std::string&) const {
std::stringstream sstream;
sstream << stream.rdbuf();
tinyxml2::XMLDocument document;
......@@ -247,7 +246,7 @@ std::vector<IItem::Pointer> WebDav::listDirectoryResponse(const IItem&,
throw std::logic_error("failed to parse xml");
if (document.RootElement()->FirstChild() == nullptr) return {};
std::vector<IItem::Pointer> result;
IItem::List result;
for (auto child = document.RootElement()->FirstChild()->NextSibling(); child;
child = child->NextSibling()) {
result.push_back(toItem(child));
......
......@@ -75,7 +75,7 @@ class WebDav : public CloudProvider {
IHttpRequest::Pointer getGeneralDataRequest(std::ostream&) const override;
IItem::Pointer getItemDataResponse(std::istream& response) const override;
std::vector<IItem::Pointer> listDirectoryResponse(
IItem::List listDirectoryResponse(
const IItem&, std::istream&, std::string& next_page_token) const override;
IItem::Pointer renameItemResponse(const IItem& old_item,
const std::string& name,
......
......@@ -355,10 +355,10 @@ IItem::Pointer YandexDisk::moveItemResponse(const IItem& source,
source.size(), source.timestamp(), source.type());
}
std::vector<IItem::Pointer> YandexDisk::listDirectoryResponse(
IItem::List YandexDisk::listDirectoryResponse(
const IItem&, std::istream& stream, std::string& next_page_token) const {
auto response = util::json::from_stream(stream);
std::vector<IItem::Pointer> result;
IItem::List result;
for (const Json::Value& v : response["_embedded"]["items"])
result.push_back(toItem(v));
int offset = response["_embedded"]["offset"].asInt();
......
......@@ -67,7 +67,7 @@ class YandexDisk : public CloudProvider {
IHttpRequest::Pointer moveItemRequest(const IItem&, const IItem&,
std::ostream&) const override;
std::vector<IItem::Pointer> listDirectoryResponse(
IItem::List listDirectoryResponse(
const IItem&, std::istream&, std::string& next_page_token) const override;
IItem::Pointer getItemDataResponse(std::istream& response) const override;
std::string getItemUrlResponse(const IItem&,
......
......@@ -424,9 +424,9 @@ IItem::Pointer YouTube::getItemDataResponse(std::istream& stream, bool audio,
high_quality);
}
std::vector<IItem::Pointer> YouTube::listDirectoryResponse(
const IItem& directory, std::istream& stream,
std::string& next_page_token) const {
IItem::List YouTube::listDirectoryResponse(const IItem& directory,
std::istream& stream,
std::string& next_page_token) const {
std::unique_ptr<Json::CharReader> reader(
Json::CharReaderBuilder().newCharReader());
std::stringstream sstream;
......@@ -434,7 +434,7 @@ std::vector<IItem::Pointer> YouTube::listDirectoryResponse(
std::string str = sstream.str();
Json::Value response;
reader->parse(str.data(), str.data() + str.size(), &response, nullptr);
std::vector<IItem::Pointer> result;
IItem::List result;
bool audio = from_string(directory.id()).audio;
bool high_quality = from_string(directory.id()).high_quality;
if (response["kind"].asString() == "youtube#channelListResponse") {
......
......@@ -59,7 +59,7 @@ class YouTube : public CloudProvider {
IItem::Pointer getItemDataResponse(std::istream& response, bool audio,
bool high_quality) const;
std::vector<IItem::Pointer> listDirectoryResponse(
IItem::List listDirectoryResponse(
const IItem& directory, std::istream&,
std::string& next_page_token) const override;
GeneralData getGeneralDataResponse(std::istream& response) const override;
......
......@@ -46,8 +46,7 @@ class ICloudProvider {
using ExchangeCodeRequest = IRequest<EitherError<Token>>;
using GetItemUrlRequest = IRequest<EitherError<std::string>>;
using ListDirectoryPageRequest = IRequest<EitherError<PageData>>;
using ListDirectoryRequest =
IRequest<EitherError<std::vector<IItem::Pointer>>>;
using ListDirectoryRequest = IRequest<EitherError<IItem::List>>;
using GetItemRequest = IRequest<EitherError<IItem>>;
using DownloadFileRequest = IRequest<EitherError<void>>;
using UploadFileRequest = IRequest<EitherError<IItem>>;
......
......@@ -37,7 +37,7 @@ GetItemRequest::GetItemRequest(std::shared_ptr<CloudProvider> p,
GetItemRequest::~GetItemRequest() { cancel(); }
IItem::Pointer GetItemRequest::getItem(const std::vector<IItem::Pointer>& items,
IItem::Pointer GetItemRequest::getItem(const IItem::List& items,
const std::string& name) const {
for (const IItem::Pointer& i : items)
if (i->filename() == name) return i;
......
......@@ -37,7 +37,7 @@ class GetItemRequest : public Request<EitherError<IItem>> {
~GetItemRequest();
private:
IItem::Pointer getItem(const std::vector<IItem::Pointer>& items,
IItem::Pointer getItem(const IItem::List& items,
const std::string& name) const;
void work(IItem::Pointer item, std::string path, Callback);
};
......
......@@ -32,8 +32,7 @@ namespace cloudstorage {
ListDirectoryRequest::ListDirectoryRequest(std::shared_ptr<CloudProvider> p,
IItem::Pointer directory,
ICallback::Pointer cb)
: Request(p,
[=](EitherError<std::vector<IItem::Pointer>> e) { cb->done(e); },
: Request(p, [=](EitherError<IItem::List> e) { cb->done(e); },
std::bind(&ListDirectoryRequest::resolve, this, _1, directory,
cb.get())) {}
......
......@@ -29,8 +29,7 @@
namespace cloudstorage {
class ListDirectoryRequest
: public Request<EitherError<std::vector<IItem::Pointer>>> {
class ListDirectoryRequest : public Request<EitherError<IItem::List>> {
public:
using ICallback = IListDirectoryCallback;
......@@ -42,7 +41,7 @@ class ListDirectoryRequest
void resolve(Request::Pointer, IItem::Pointer directory, ICallback* cb);
void work(IItem::Pointer directory, std::string page_token, ICallback*);
std::vector<IItem::Pointer> result_;
IItem::List result_;
};
} // namespace cloudstorage
......
......@@ -55,8 +55,7 @@ void RecursiveRequest<T>::visit(typename Request<T>::Pointer r,
}
template <class T>
void RecursiveRequest<T>::visit(typename Request<T>::Pointer r,
std::vector<IItem::Pointer> lst,
void RecursiveRequest<T>::visit(typename Request<T>::Pointer r, IItem::List lst,
CompleteCallback callback, Visitor visitor) {
if (lst.empty()) return callback(T());
auto i = lst.back();
......
......@@ -41,8 +41,8 @@ class RecursiveRequest : public Request<ReturnValue> {
private:
static void visit(typename Request<ReturnValue>::Pointer, IItem::Pointer item,
CompleteCallback, Visitor);
static void visit(typename Request<ReturnValue>::Pointer,
std::vector<IItem::Pointer> lst, CompleteCallback, Visitor);
static void visit(typename Request<ReturnValue>::Pointer, IItem::List lst,
CompleteCallback, Visitor);
};
} // namespace cloudstorage
......
......@@ -308,7 +308,7 @@ template class Request<EitherError<Token>>;
template class Request<EitherError<std::vector<char>>>;
template class Request<EitherError<std::string>>;
template class Request<EitherError<IItem>>;
template class Request<EitherError<std::vector<IItem::Pointer>>>;
template class Request<EitherError<IItem::List>>;
template class Request<EitherError<void>>;
template class Request<EitherError<GeneralData>>;
......
......@@ -347,8 +347,7 @@ void FileSystem::readdir(FileId node, ListDirectoryCallback cb) {
auto nd = get(node);
if (nd->provider() == nullptr) return cb(Error{IHttpRequest::Bad, ""});
list_directory_async(
nd->provider(), nd->item(),
[=](EitherError<std::vector<IItem::Pointer>> e) {
nd->provider(), nd->item(), [=](EitherError<IItem::List> e) {
if (auto lst = e.right()) {
std::unordered_set<FileId> ret;
for (auto&& i : *lst)
......
......@@ -147,8 +147,7 @@ class CloudProviderTest : public ::testing::Test {
}
}
static std::vector<std::string> filename(
const std::vector<IItem::Pointer>& lst) {
static std::vector<std::string> filename(const IItem::List& lst) {
std::vector<std::string> result;
for (auto p : lst) result.push_back(p->filename());
std::sort(result.begin(), result.end());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment