clean seafile api
This commit is contained in:
1 parent
3e4694ceb5
commit
f0c5de374e
4 files changed
+30
-38
No files matched your search
@@ -22,10 +22,6 @@ namespace seafile::fs
|
||||
Type type;
|
||||
|
||||
uint64_t size{};
|
||||
|
||||
std::string download_url;
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
#define SEADISK_VERSION_HPP
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <compare>
|
||||
|
||||
namespace seafile::util
|
||||
{
|
||||
|
||||
namespace seafile::util {
|
||||
/**
|
||||
* @brief Semantic version parser.
|
||||
*
|
||||
@@ -18,12 +17,19 @@ namespace seafile::util
|
||||
* 10.0
|
||||
* 10.0.2
|
||||
*/
|
||||
class Version final
|
||||
{
|
||||
class Version final {
|
||||
public:
|
||||
Version() = default;
|
||||
|
||||
explicit Version(const std::string& version);
|
||||
explicit Version(const std::string &version);
|
||||
|
||||
Version(const Version &) = default;
|
||||
|
||||
Version(Version &&) noexcept = default;
|
||||
|
||||
Version &operator=(const Version &) = default;
|
||||
|
||||
Version &operator=(Version &&) noexcept = default;
|
||||
|
||||
[[nodiscard]]
|
||||
int major() const noexcept;
|
||||
@@ -37,19 +43,14 @@ namespace seafile::util
|
||||
[[nodiscard]]
|
||||
std::string toString() const;
|
||||
|
||||
bool operator==(const Version& other) const;
|
||||
|
||||
bool operator<(const Version& other) const;
|
||||
|
||||
std::strong_ordering operator<=>(const Version &other) const;
|
||||
|
||||
private:
|
||||
void parse(const std::string& version);
|
||||
void parse(const std::string &version);
|
||||
|
||||
private:
|
||||
int major_{0};
|
||||
std::optional<int> minor_;
|
||||
std::optional<int> patch_;
|
||||
};
|
||||
|
||||
}
|
||||
#endif //SEADISK_VERSION_HPP
|
||||
@@ -54,7 +54,6 @@ namespace seafile::fs
|
||||
const auto authToken = api->auth(username, password);
|
||||
if (authToken.has_value())
|
||||
{
|
||||
this->token = authToken.value().token;
|
||||
if (const auto repo = api->defaultRepo(); repo.has_value())
|
||||
{
|
||||
this->repo_id = repo.value().repo_id.value_or("");
|
||||
@@ -140,7 +139,7 @@ namespace seafile::fs
|
||||
auto repo = api->repoInfo(repo_id);
|
||||
if (!repo.has_value())
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
const auto ctx = new SeaFileContext{repo->id, path, SeaFileContext::Type::DIRECTORY, 0, ""};
|
||||
const auto ctx = new SeaFileContext{repo->id, path, SeaFileContext::Type::DIRECTORY, 0};
|
||||
*PFileContext = ctx;
|
||||
SetFileInfo(FileInfo, FILE_ATTRIBUTE_DIRECTORY, repo->size, repo->mtime);
|
||||
spdlog::info(std::format("open directory {} success", path));
|
||||
@@ -150,7 +149,7 @@ namespace seafile::fs
|
||||
if (const auto dirInfo = api->dirDetail(repo_id, path); dirInfo.has_value())
|
||||
{
|
||||
const auto& info = dirInfo.value();
|
||||
const auto ctx = new SeaFileContext{info.repo_id, info.path, SeaFileContext::Type::DIRECTORY, 0, ""};
|
||||
const auto ctx = new SeaFileContext{info.repo_id, info.path, SeaFileContext::Type::DIRECTORY, 0};
|
||||
*PFileContext = ctx;
|
||||
SetFileInfo(FileInfo,FILE_ATTRIBUTE_DIRECTORY, 0, 0);
|
||||
spdlog::info(std::format("open directory {} success", path));
|
||||
@@ -161,7 +160,7 @@ namespace seafile::fs
|
||||
if (const auto fileInfo = api->fileDetail(repo_id, path); fileInfo.has_value())
|
||||
{
|
||||
const auto& info = fileInfo.value();
|
||||
const auto ctx = new SeaFileContext(repo_id, path, SeaFileContext::Type::FILE, info.size, "");
|
||||
const auto ctx = new SeaFileContext(repo_id, path, SeaFileContext::Type::FILE, info.size);
|
||||
*PFileContext = ctx;
|
||||
SetFileInfo(FileInfo,FILE_ATTRIBUTE_ARCHIVE, info.size, 0);
|
||||
spdlog::info(std::format("open file {} success", path));
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <seafile/util/version.hpp>
|
||||
#include <tuple>
|
||||
|
||||
namespace seafile::util {
|
||||
Version::Version(const std::string &version) {
|
||||
@@ -43,23 +44,18 @@ namespace seafile::util {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Version::operator==(const Version &other) const {
|
||||
return major_ == other.major_
|
||||
&& minor().value_or(0) == other.minor().value_or(0)
|
||||
&& patch().value_or(0) == other.patch().value_or(0);
|
||||
}
|
||||
|
||||
|
||||
bool Version::operator<(const Version &other) const {
|
||||
if (major_ != other.major_) {
|
||||
return major_ < other.major_;
|
||||
}
|
||||
|
||||
if (minor().value_or(0) != other.minor().value_or(0)) {
|
||||
return minor().value_or(0) < other.minor().value_or(0);
|
||||
}
|
||||
|
||||
return patch().value_or(0) < other.patch().value_or(0);
|
||||
std::strong_ordering Version::operator<=>(const Version &other) const {
|
||||
const auto lhs = std::tuple{
|
||||
major(),
|
||||
minor().value_or(0),
|
||||
patch().value_or(0)
|
||||
};
|
||||
const auto rhs = std::tuple{
|
||||
other.major(),
|
||||
other.minor().value_or(0),
|
||||
other.patch().value_or(0)
|
||||
};
|
||||
return lhs <=> rhs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user