mirror of
https://github.com/typesense/typesense.git
synced 2025-05-17 20:22:32 +08:00
Some checks are pending
tests / test (push) Waiting to run
* add: support for .tar.gz files * refactor: binary_body parsing and move content-type to http_server.h * add: libarchive * update: BUILD file * fxi: bazel convecntions * add: archive utils helper classes * fix: memory leaks * refactor: change the flow to cleanup everything at last * add: archiver tests * rm: test endpoints * fix: set data-dir on ArchiveUtilsTest * add: a const value in http_data.h * fix: a const value in http_data.h
23 lines
787 B
C++
23 lines
787 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <archive.h>
|
|
#include <archive_entry.h>
|
|
#include <fcntl.h>
|
|
#include <sys/stat.h>
|
|
|
|
class ArchiveUtils {
|
|
public:
|
|
static constexpr const char* TAR_GZ_EXTENSION = ".tar.gz";
|
|
static bool extract_tar_gz_from_file(const std::string& archive_path, const std::string& destination_path);
|
|
static bool extract_tar_gz_from_memory(const std::string& archive_content, const std::string& destination_path);
|
|
private:
|
|
static constexpr size_t BUFFER_SIZE = (10 * 1024 * 1024);
|
|
|
|
static int copy_data(struct archive* ar, struct archive* aw);
|
|
static bool create_directory(const std::string& path);
|
|
static std::string create_temp_tar_gz(const std::string& content);
|
|
static void cleanup(const std::string& file_path);
|
|
};
|