Commit 4e3f1ef7 authored by Paweł Wegner's avatar Paweł Wegner

LocalDrive: implemented getGeneralData.

parent 596e4223
......@@ -304,6 +304,23 @@ LocalDrive::GetItemDataRequest::Pointer LocalDrive::getItemDataAsync(
});
}
LocalDrive::GeneralDataRequest::Pointer LocalDrive::getGeneralDataAsync(
GeneralDataCallback callback) {
return request<EitherError<GeneralData>>(
[=](EitherError<GeneralData> e) { callback(e); },
[=](Request<EitherError<GeneralData>>::Pointer r) {
fs::path path(this->path());
error_code error;
auto space = fs::space(path, error);
if (error) return r->done(Error{error.value(), error.message()});
GeneralData data;
data.space_used_ = space.capacity - space.available;
data.space_total_ = space.capacity;
data.username_ = this->path();
r->done(data);
});
}
bool LocalDrive::unpackCredentials(const std::string &code) {
auto lock = auth_lock();
try {
......
......@@ -68,6 +68,8 @@ class LocalDrive : public CloudProvider {
RenameItemCallback) override;
GetItemDataRequest::Pointer getItemDataAsync(const std::string& id,
GetItemDataCallback f) override;
GeneralDataRequest::Pointer getGeneralDataAsync(GeneralDataCallback) override;
std::string path(IItem::Pointer) const;
private:
......
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