添加本地存储
This commit is contained in:
1 parent
95b68b9542
commit
e8b91b1a59
5 files changed
+255
No files matched your search
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// Created by Shell on 2026/7/16.
|
||||
//
|
||||
|
||||
#ifndef SEADISK_SEAFILE_STORE_HPP
|
||||
#define SEADISK_SEAFILE_STORE_HPP
|
||||
#include "seafile/api/seafile_api.hpp"
|
||||
#include <sqlite_orm/sqlite_orm.h>
|
||||
|
||||
#include "storage/repo_entry.hpp"
|
||||
|
||||
namespace seafile::fs {
|
||||
|
||||
|
||||
class SeafileStore final {
|
||||
public:
|
||||
|
||||
/// construction
|
||||
/// @param db_path database file path
|
||||
/// @param server the server url of seafile
|
||||
/// @param user user
|
||||
/// @param password password
|
||||
SeafileStore(const std::string &db_path, const std::string &server, const std::string &user,
|
||||
const std::string &password);
|
||||
|
||||
SeafileStore(const SeafileStore &) = default;
|
||||
|
||||
tl::expected<void,api::SeafileException> auth();
|
||||
|
||||
/// 检查是否已经更新到最新
|
||||
/// @return true 已经最新,false 需要更新
|
||||
tl::expected<bool, api::SeafileException> checkIsUpdated(const std::string& repo_id);
|
||||
|
||||
/// 检查是否需要更新元素据,如果需要同步则自动同步
|
||||
tl::expected<void, api::SeafileException> checkAndSync(const std::string& repo_id,);
|
||||
|
||||
/// 同步元数据
|
||||
tl::expected<void, api::SeafileException> sync(const std::string& repo_id);
|
||||
|
||||
/// 获取路径信息
|
||||
/// @param path 路径
|
||||
/// @return 路径信息
|
||||
tl::expected<storage::RepoEntry, api::SeafileException> findRepoEntry(const std::string& repo_id, const std::string &path);
|
||||
|
||||
private:
|
||||
struct Database;
|
||||
std::unique_ptr<Database> database;
|
||||
std::string api_server;
|
||||
std::string user;
|
||||
std::string password;
|
||||
std::string token;
|
||||
api::TokenType token_type = api::TokenType::TOKEN;
|
||||
api::SeaFileApi api;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //SEADISK_SEAFILE_STORE_HPP
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Created by Shell on 2026/7/16.
|
||||
//
|
||||
|
||||
#ifndef SEADISK_STORAGE_REPO_ENTRY_HPP
|
||||
#define SEADISK_STORAGE_REPO_ENTRY_HPP
|
||||
#include "seafile/api/repo_entry.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace seafile::fs::storage {
|
||||
struct RepoEntry final {
|
||||
///repo id
|
||||
std::string repo_id;
|
||||
|
||||
///entry path
|
||||
std::string path;
|
||||
|
||||
/// Entry type ("file" or "dir").
|
||||
std::string type;
|
||||
|
||||
/// File or directory name.
|
||||
std::string name;
|
||||
|
||||
/// Object identifier.
|
||||
std::string id;
|
||||
|
||||
/// Last modification time (Unix timestamp, seconds).
|
||||
std::int64_t mtime{};
|
||||
|
||||
/// Internal email address of the last modifier.
|
||||
std::optional<std::string> modifier_email;
|
||||
|
||||
/// File size in bytes. For directories this may be 0.
|
||||
std::optional<std::uint64_t> size{};
|
||||
|
||||
/// Whether the file is currently locked.
|
||||
std::optional<bool> is_locked{};
|
||||
|
||||
/// Lock owner email or identifier. Null if unlocked.
|
||||
std::optional<std::string> lock_owner;
|
||||
|
||||
/// Lock timestamp (Unix timestamp, seconds).
|
||||
std::optional<std::int64_t> lock_time{};
|
||||
|
||||
/// Whether the current user owns the lock.
|
||||
std::optional<bool> locked_by_me{};
|
||||
|
||||
/// Current user's permission (e.g. "r", "rw").
|
||||
std::optional<std::string> permission;
|
||||
|
||||
/// Contact email address of the last modifier.
|
||||
std::optional<std::string> modifier_contact_email;
|
||||
|
||||
/// Display name of the last modifier.
|
||||
std::optional<std::string> modifier_name;
|
||||
|
||||
/// Whether the entry is starred by the current user.
|
||||
std::optional<bool> starred{};
|
||||
};
|
||||
}
|
||||
#endif //SEADISK_STORAGE_REPO_ENTRY_HPP
|
||||
Reference in new issue
Block a user