2017-10-09 20:48:10 +05:00
|
|
|
#ifndef NNTPCHAN_STORAGE_HPP
|
|
|
|
#define NNTPCHAN_STORAGE_HPP
|
|
|
|
|
|
|
|
#include "file_handle.hpp"
|
2017-10-13 16:58:41 +05:00
|
|
|
#include "message.hpp"
|
2017-10-17 19:29:56 +05:00
|
|
|
#include <experimental/filesystem>
|
|
|
|
#include <string>
|
2017-10-09 20:48:10 +05:00
|
|
|
|
|
|
|
namespace nntpchan
|
|
|
|
{
|
|
|
|
|
2017-10-17 19:29:56 +05:00
|
|
|
namespace fs = std::experimental::filesystem;
|
2017-10-09 20:48:10 +05:00
|
|
|
|
2017-10-17 19:29:56 +05:00
|
|
|
class ArticleStorage : public MessageDB
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ArticleStorage(const fs::path &fpath);
|
|
|
|
~ArticleStorage();
|
2017-10-09 20:48:10 +05:00
|
|
|
|
2017-10-17 19:29:56 +05:00
|
|
|
FileHandle_ptr OpenWrite(const std::string &msgid) const;
|
|
|
|
FileHandle_ptr OpenRead(const std::string &msgid) const;
|
2017-10-13 16:58:41 +05:00
|
|
|
|
2017-10-17 19:29:56 +05:00
|
|
|
/**
|
|
|
|
return true if we should accept a new message give its message id
|
|
|
|
*/
|
|
|
|
bool Accept(const std::string &msgid) const;
|
2017-10-13 16:58:41 +05:00
|
|
|
|
2017-10-17 19:29:56 +05:00
|
|
|
bool LoadBoardPage(BoardPage &board, const std::string &newsgroup, uint32_t perpage, uint32_t page) const;
|
|
|
|
bool FindThreadByHash(const std::string &hashhex, std::string &msgid) const;
|
|
|
|
bool LoadThread(Thread &thread, const std::string &rootmsgid) const;
|
2017-10-13 16:58:41 +05:00
|
|
|
|
2017-10-17 19:29:56 +05:00
|
|
|
/** ensure symlinks are formed for this article by message id */
|
|
|
|
void EnsureSymlinks(const std::string &msgid) const;
|
2017-10-09 20:48:10 +05:00
|
|
|
|
2017-10-17 19:29:56 +05:00
|
|
|
private:
|
|
|
|
void SetPath(const fs::path &fpath);
|
2017-10-09 20:48:10 +05:00
|
|
|
|
2017-10-17 19:29:56 +05:00
|
|
|
fs::path MessagePath(const std::string &msgid) const;
|
2017-10-09 20:48:10 +05:00
|
|
|
|
2017-10-17 19:29:56 +05:00
|
|
|
bool init_skiplist(const std::string &subdir) const;
|
2017-10-13 16:58:41 +05:00
|
|
|
|
2017-10-17 19:29:56 +05:00
|
|
|
fs::path skiplist_root(const std::string &name) const;
|
2017-10-24 17:51:21 +05:00
|
|
|
fs::path skiplist_dir(const fs::path & root, const std::string & name) const;
|
2017-10-09 20:48:10 +05:00
|
|
|
|
2017-10-17 19:29:56 +05:00
|
|
|
fs::path basedir;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::unique_ptr<ArticleStorage> ArticleStorage_ptr;
|
|
|
|
}
|
2017-10-09 20:48:10 +05:00
|
|
|
|
|
|
|
#endif
|