Commit 4ba9f240 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Fix argument order in boost::filesystem::relative

Closes #5.
parent bcdc16ad
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ build:ubuntu_latest:
            protobuf-c-compiler
            libyaml-cpp-dev
            libyaml-dev
            libcap2-bin
          
    # Build and test
    script:
@@ -41,4 +42,4 @@ build:ubuntu_latest:
        - make -j4
        - cd tests
        - make -j4 api
        - NORNS_DEBUG_OUTPUT_TO_STDERR=1 NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api -as
        - NORNS_DEBUG_OUTPUT_TO_STDERR=1 NORNS_DEBUG_CONFIG_FILE_OVERRIDE=1 ./api 2> /tmp/test_logs/stderr.log
+29 −19
Original line number Diff line number Diff line
@@ -333,8 +333,33 @@ void request::cleanup() {
namespace detail {

template<>
std::string bad_request::to_string() const {
    return "BAD_REQUEST";
std::string iotask_create_request::to_string() const {

    const auto op = this->get<0>();
    const auto src = this->get<1>();
    const auto dst = this->get<2>();

    return utils::to_string(op) + ", "
           + src->to_string() + " => "
           + dst->to_string();
}

template<>
std::string iotask_status_request::to_string() const {

    const auto tid = this->get<0>();

    return std::to_string(tid);
}

template<>
std::string ctl_status_request::to_string() const {
    return "GLOBAL_STATUS";
}

template<>
std::string ping_request::to_string() const {
    return "PING";
}

template<>
@@ -458,23 +483,8 @@ std::string backend_unregister_request::to_string() const {
}

template<>
std::string iotask_create_request::to_string() const {

    const auto op = this->get<0>();
    const auto src = this->get<1>();
    const auto dst = this->get<2>();

    return utils::to_string(op) + ", "
           + src->to_string() + " => "
           + dst->to_string();
}

template<>
std::string iotask_status_request::to_string() const {

    const auto tid = this->get<0>();

    return std::to_string(tid);
std::string bad_request::to_string() const {
    return "BAD_REQUEST";
}

} // namespace detail
+1 −3
Original line number Diff line number Diff line
@@ -165,9 +165,7 @@ struct request_impl : std::tuple<FieldTypes...>, request {
    // this is the implementation for the generic to_string() 
    // function for any RT that is not known. For known RTs, we 
    // provide concrete specializations in the cpp file
    std::string to_string() const override {
        return "UNKNOWN_REQUEST";
    }
    std::string to_string() const override;

    template <std::size_t I>
    typename std::tuple_element<I, std::tuple<FieldTypes...>>::type get() const {
+2 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include "posix-fs.hpp"
#include "utils.hpp"
#include "logger.hpp"
#include <iostream>

namespace bfs = boost::filesystem;

@@ -116,7 +117,7 @@ backend::resource_ptr posix_filesystem::get_resource(const resource_info_ptr& ri

    // path exists: compute the absolute subpath considering the backend mount as root
    const bfs::path ns_abs_subpath = bfs::path("/") / 
                                bfs::relative(m_mount, canonical_path) /
                                bfs::relative(canonical_path, m_mount) /
                                (bfs::is_directory(canonical_path) ? "/" : "");

    // if the computed subpath is relative, it means that the canonical_path
+5 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include "io/task-info.hpp"
#include "backends/posix-fs.hpp"
#include "local-path-to-local-path.hpp"
#include <iostream>

namespace {

@@ -49,6 +50,9 @@ get_filesize(int fd) {
        return static_cast<ssize_t>(st.st_size);
    }

    LOGGER_ERROR("fstat() failed: {}", 
            std::make_error_code(static_cast<std::errc>(errno)).message());

    return static_cast<ssize_t>(-1);
}

@@ -154,7 +158,7 @@ copy_directory(const std::shared_ptr<norns::io::task_info>& task_info,
    auto start = std::chrono::steady_clock::now();

    for(; it != end; ++it) {
        const auto dst_path = dst / bfs::relative(src, *it);
        const auto dst_path = dst / bfs::relative(*it, src);

        if(bfs::is_directory(*it)) {
            if(!bfs::exists(dst_path)) {
Loading