Compare commits
	
		
			1 Commits
		
	
	
		
			v2.0.6-rel
			...
			v2.0.7-rel
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 5ab7301cbe | 
@@ -1,5 +1,11 @@
 | 
				
			|||||||
# Changelog
 | 
					# Changelog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## v2.0.7-release
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Issues
 | 
				
			||||||
 | 
					* \#55 [bug] UI is unable to launch `repertory.exe` on Windows when absolute path contains spaces
 | 
				
			||||||
 | 
					* \#57 [bug] Directory entries . and .. are incorrectly being reported as files in Linux remote mounts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## v2.0.6-release
 | 
					## v2.0.6-release
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Issues
 | 
					### Issues
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,7 @@ PROJECT_DESC="Mount utility for Sia and S3"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
PROJECT_MAJOR_VERSION=2
 | 
					PROJECT_MAJOR_VERSION=2
 | 
				
			||||||
PROJECT_MINOR_VERSION=0
 | 
					PROJECT_MINOR_VERSION=0
 | 
				
			||||||
PROJECT_REVISION_VERSION=6
 | 
					PROJECT_REVISION_VERSION=7
 | 
				
			||||||
PROJECT_RELEASE_NUM=1
 | 
					PROJECT_RELEASE_NUM=1
 | 
				
			||||||
PROJECT_RELEASE_ITER=release
 | 
					PROJECT_RELEASE_ITER=release
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -102,7 +102,7 @@ void remote_fuse_drive::destroy_impl(void *ptr) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (remote_instance_) {
 | 
					  if (remote_instance_) {
 | 
				
			||||||
    const auto res = remote_instance_->fuse_destroy();
 | 
					    auto res = remote_instance_->fuse_destroy();
 | 
				
			||||||
    if (res != 0) {
 | 
					    if (res != 0) {
 | 
				
			||||||
      utils::error::raise_error(function_name,
 | 
					      utils::error::raise_error(function_name,
 | 
				
			||||||
                                "remote fuse_destroy() failed|err|" +
 | 
					                                "remote fuse_destroy() failed|err|" +
 | 
				
			||||||
@@ -128,7 +128,7 @@ auto remote_fuse_drive::fgetattr_impl(std::string api_path,
 | 
				
			|||||||
  remote::stat r_stat{};
 | 
					  remote::stat r_stat{};
 | 
				
			||||||
  auto directory = false;
 | 
					  auto directory = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const auto res = remote_instance_->fuse_fgetattr(api_path.c_str(), r_stat,
 | 
					  auto res = remote_instance_->fuse_fgetattr(api_path.c_str(), r_stat,
 | 
				
			||||||
                                             directory, f_info->fh);
 | 
					                                             directory, f_info->fh);
 | 
				
			||||||
  if (res == 0) {
 | 
					  if (res == 0) {
 | 
				
			||||||
    populate_stat(r_stat, directory, *unix_st);
 | 
					    populate_stat(r_stat, directory, *unix_st);
 | 
				
			||||||
@@ -191,7 +191,7 @@ auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st)
 | 
				
			|||||||
  bool directory = false;
 | 
					  bool directory = false;
 | 
				
			||||||
  remote::stat r_stat{};
 | 
					  remote::stat r_stat{};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const auto res =
 | 
					  auto res =
 | 
				
			||||||
      remote_instance_->fuse_getattr(api_path.c_str(), r_stat, directory);
 | 
					      remote_instance_->fuse_getattr(api_path.c_str(), r_stat, directory);
 | 
				
			||||||
  if (res == 0) {
 | 
					  if (res == 0) {
 | 
				
			||||||
    populate_stat(r_stat, directory, *unix_st);
 | 
					    populate_stat(r_stat, directory, *unix_st);
 | 
				
			||||||
@@ -208,9 +208,9 @@ api_error remote_fuse_drive::getxtimes_impl(std::string api_path,
 | 
				
			|||||||
    return utils::to_api_error(-EFAULT);
 | 
					    return utils::to_api_error(-EFAULT);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  remote::file_time repertory_bkuptime = 0u;
 | 
					  remote::file_time repertory_bkuptime{0U};
 | 
				
			||||||
  remote::file_time repertory_crtime = 0u;
 | 
					  remote::file_time repertory_crtime{0U};
 | 
				
			||||||
  const auto res = remote_instance_->fuse_getxtimes(
 | 
					  auto res = remote_instance_->fuse_getxtimes(
 | 
				
			||||||
      api_path.c_str(), repertory_bkuptime, repertory_crtime);
 | 
					      api_path.c_str(), repertory_bkuptime, repertory_crtime);
 | 
				
			||||||
  if (res == 0) {
 | 
					  if (res == 0) {
 | 
				
			||||||
    bkuptime->tv_nsec =
 | 
					    bkuptime->tv_nsec =
 | 
				
			||||||
@@ -390,20 +390,42 @@ auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf,
 | 
				
			|||||||
                                     struct fuse_file_info *f_info)
 | 
					                                     struct fuse_file_info *f_info)
 | 
				
			||||||
    -> api_error {
 | 
					    -> api_error {
 | 
				
			||||||
#endif // FUSE_USE_VERSION >= 30
 | 
					#endif // FUSE_USE_VERSION >= 30
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  std::string item_path;
 | 
					  std::string item_path;
 | 
				
			||||||
  int res = 0;
 | 
					  int res{0};
 | 
				
			||||||
  while ((res = remote_instance_->fuse_readdir(
 | 
					  while ((res = remote_instance_->fuse_readdir(
 | 
				
			||||||
              api_path.c_str(), static_cast<remote::file_offset>(offset),
 | 
					              api_path.c_str(), static_cast<remote::file_offset>(offset),
 | 
				
			||||||
              f_info->fh, item_path)) == 0) {
 | 
					              f_info->fh, item_path)) == 0) {
 | 
				
			||||||
    if ((item_path != ".") && (item_path != "..")) {
 | 
					    std::unique_ptr<struct stat> p_stat{nullptr};
 | 
				
			||||||
 | 
					    int stat_res{0};
 | 
				
			||||||
 | 
					    if ((item_path == ".") || (item_path == "..")) {
 | 
				
			||||||
 | 
					      p_stat = std::make_unique<struct stat>();
 | 
				
			||||||
 | 
					      std::memset(p_stat.get(), 0, sizeof(struct stat));
 | 
				
			||||||
 | 
					      if (item_path == ".") {
 | 
				
			||||||
 | 
					        stat_res =
 | 
				
			||||||
 | 
					            stat(utils::path::combine(get_mount_location(), {api_path}).c_str(),
 | 
				
			||||||
 | 
					                 p_stat.get());
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        stat_res =
 | 
				
			||||||
 | 
					            stat(utils::path::get_parent_path(
 | 
				
			||||||
 | 
					                     utils::path::combine(get_mount_location(), {api_path}))
 | 
				
			||||||
 | 
					                     .c_str(),
 | 
				
			||||||
 | 
					                 p_stat.get());
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (stat_res != 0) {
 | 
				
			||||||
 | 
					        res = stat_res;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
      item_path = utils::path::strip_to_file_name(item_path);
 | 
					      item_path = utils::path::strip_to_file_name(item_path);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if FUSE_USE_VERSION >= 30
 | 
					#if FUSE_USE_VERSION >= 30
 | 
				
			||||||
    if (fuse_fill_dir(buf, item_path.c_str(), nullptr, ++offset,
 | 
					    if (fuse_fill_dir(buf, item_path.c_str(), p_stat.get(), ++offset,
 | 
				
			||||||
                      static_cast<fuse_fill_dir_flags>(0)) != 0) {
 | 
					                      FUSE_FILL_DIR_PLUS) != 0) {
 | 
				
			||||||
#else  // FUSE_USE_VERSION < 30
 | 
					#else  // FUSE_USE_VERSION < 30
 | 
				
			||||||
    if (fuse_fill_dir(buf, item_path.c_str(), nullptr, ++offset) != 0) {
 | 
					    if (fuse_fill_dir(buf, item_path.c_str(), p_stat.get(), ++offset) != 0) {
 | 
				
			||||||
#endif // FUSE_USE_VERSION >= 30
 | 
					#endif // FUSE_USE_VERSION >= 30
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -592,7 +614,7 @@ auto remote_fuse_drive::write_impl(std::string api_path, const char *buffer,
 | 
				
			|||||||
                                   size_t write_size, off_t write_offset,
 | 
					                                   size_t write_size, off_t write_offset,
 | 
				
			||||||
                                   struct fuse_file_info *f_info,
 | 
					                                   struct fuse_file_info *f_info,
 | 
				
			||||||
                                   std::size_t &bytes_written) -> api_error {
 | 
					                                   std::size_t &bytes_written) -> api_error {
 | 
				
			||||||
  const auto res = remote_instance_->fuse_write(
 | 
					  auto res = remote_instance_->fuse_write(
 | 
				
			||||||
      api_path.c_str(), buffer, write_size,
 | 
					      api_path.c_str(), buffer, write_size,
 | 
				
			||||||
      static_cast<remote::file_offset>(write_offset), f_info->fh);
 | 
					      static_cast<remote::file_offset>(write_offset), f_info->fh);
 | 
				
			||||||
  if (res >= 0) {
 | 
					  if (res >= 0) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,6 +38,7 @@
 | 
				
			|||||||
#include <boost/process/v1/args.hpp>
 | 
					#include <boost/process/v1/args.hpp>
 | 
				
			||||||
#include <boost/process/v1/child.hpp>
 | 
					#include <boost/process/v1/child.hpp>
 | 
				
			||||||
#include <boost/process/v1/io.hpp>
 | 
					#include <boost/process/v1/io.hpp>
 | 
				
			||||||
 | 
					namespace bp1 = boost::process::v1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace {
 | 
					namespace {
 | 
				
			||||||
[[nodiscard]] auto decrypt(std::string_view data, std::string_view password)
 | 
					[[nodiscard]] auto decrypt(std::string_view data, std::string_view password)
 | 
				
			||||||
@@ -227,23 +228,6 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
 | 
				
			|||||||
    handle_put_settings(req, res);
 | 
					    handle_put_settings(req, res);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static std::atomic<httplib::Server *> this_server{server_};
 | 
					 | 
				
			||||||
  static const auto quit_handler = [](int /* sig */) {
 | 
					 | 
				
			||||||
    auto *ptr = this_server.load();
 | 
					 | 
				
			||||||
    if (ptr == nullptr) {
 | 
					 | 
				
			||||||
      return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    this_server = nullptr;
 | 
					 | 
				
			||||||
    ptr->stop();
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  std::signal(SIGINT, quit_handler);
 | 
					 | 
				
			||||||
#if !defined(_WIN32)
 | 
					 | 
				
			||||||
  std::signal(SIGQUIT, quit_handler);
 | 
					 | 
				
			||||||
#endif // !defined(_WIN32)
 | 
					 | 
				
			||||||
  std::signal(SIGTERM, quit_handler);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(_WIN32)
 | 
					#if defined(_WIN32)
 | 
				
			||||||
  system(fmt::format(
 | 
					  system(fmt::format(
 | 
				
			||||||
             R"(start "Repertory Management Portal" "http://127.0.0.1:{}/ui")",
 | 
					             R"(start "Repertory Management Portal" "http://127.0.0.1:{}/ui")",
 | 
				
			||||||
@@ -270,6 +254,23 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
 | 
				
			|||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static std::atomic<httplib::Server *> this_server{server_};
 | 
				
			||||||
 | 
					  static const auto quit_handler = [](int /* sig */) {
 | 
				
			||||||
 | 
					    auto *ptr = this_server.load();
 | 
				
			||||||
 | 
					    if (ptr == nullptr) {
 | 
				
			||||||
 | 
					      return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this_server = nullptr;
 | 
				
			||||||
 | 
					    ptr->stop();
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  std::signal(SIGINT, quit_handler);
 | 
				
			||||||
 | 
					#if !defined(_WIN32)
 | 
				
			||||||
 | 
					  std::signal(SIGQUIT, quit_handler);
 | 
				
			||||||
 | 
					#endif // !defined(_WIN32)
 | 
				
			||||||
 | 
					  std::signal(SIGTERM, quit_handler);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  event_system::instance().start();
 | 
					  event_system::instance().start();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  nonce_thread_ =
 | 
					  nonce_thread_ =
 | 
				
			||||||
@@ -711,19 +712,37 @@ auto handlers::launch_process(provider_type prov, std::string_view name,
 | 
				
			|||||||
  recur_mutex_lock inst_lock(inst_mtx);
 | 
					  recur_mutex_lock inst_lock(inst_mtx);
 | 
				
			||||||
  if (background) {
 | 
					  if (background) {
 | 
				
			||||||
#if defined(_WIN32)
 | 
					#if defined(_WIN32)
 | 
				
			||||||
    std::array<char, MAX_PATH + 1U> path{};
 | 
					    args.insert(args.begin(), "--hidden");
 | 
				
			||||||
    ::GetSystemDirectoryA(path.data(), path.size());
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    args.insert(args.begin(), utils::path::combine(path.data(), {"cmd.exe"}));
 | 
					    auto cmdline = fmt::format("{}{}{}", '"', repertory_binary_, '"');
 | 
				
			||||||
    args.insert(std::next(args.begin()), "/c");
 | 
					    for (const auto &arg : args) {
 | 
				
			||||||
    args.insert(std::next(args.begin(), 2U), "start");
 | 
					      cmdline += " ";
 | 
				
			||||||
    args.insert(std::next(args.begin(), 3U), "");
 | 
					      if (arg.find_first_of(" \t") != std::string::npos) {
 | 
				
			||||||
    args.insert(std::next(args.begin(), 4U), "/MIN");
 | 
					        cmdline += fmt::format("{}{}{}", '"', arg, '"');
 | 
				
			||||||
    args.insert(std::next(args.begin(), 5U), repertory_binary_);
 | 
					      } else {
 | 
				
			||||||
 | 
					        cmdline += arg;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    STARTUPINFOA start_info{};
 | 
				
			||||||
 | 
					    start_info.cb = sizeof(start_info);
 | 
				
			||||||
 | 
					    start_info.dwFlags = STARTF_USESHOWWINDOW;
 | 
				
			||||||
 | 
					    start_info.wShowWindow = SW_SHOWMINNOACTIVE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PROCESS_INFORMATION proc_info{};
 | 
				
			||||||
 | 
					    auto result = ::CreateProcessA(
 | 
				
			||||||
 | 
					        nullptr, &cmdline[0U], nullptr, nullptr, FALSE,
 | 
				
			||||||
 | 
					        CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP, nullptr,
 | 
				
			||||||
 | 
					        utils::path::get_parent_path(repertory_binary_).c_str(), &start_info,
 | 
				
			||||||
 | 
					        &proc_info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (result) {
 | 
				
			||||||
 | 
					      ::CloseHandle(proc_info.hProcess);
 | 
				
			||||||
 | 
					      ::CloseHandle(proc_info.hThread);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
#else  // !defined(_WIN32)
 | 
					#else  // !defined(_WIN32)
 | 
				
			||||||
    args.insert(args.begin(), "-f");
 | 
					 | 
				
			||||||
    args.insert(args.begin(), repertory_binary_);
 | 
					    args.insert(args.begin(), repertory_binary_);
 | 
				
			||||||
#endif // defined(_WIN32)
 | 
					    args.insert(std::next(args.begin()), "-f");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::vector<const char *> exec_args;
 | 
					    std::vector<const char *> exec_args;
 | 
				
			||||||
    exec_args.reserve(args.size() + 1U);
 | 
					    exec_args.reserve(args.size() + 1U);
 | 
				
			||||||
@@ -732,10 +751,6 @@ auto handlers::launch_process(provider_type prov, std::string_view name,
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    exec_args.push_back(nullptr);
 | 
					    exec_args.push_back(nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(_WIN32)
 | 
					 | 
				
			||||||
    _spawnv(_P_DETACH, exec_args.at(0U),
 | 
					 | 
				
			||||||
            const_cast<char *const *>(exec_args.data()));
 | 
					 | 
				
			||||||
#else  // !defined(_WIN32)
 | 
					 | 
				
			||||||
    auto pid = fork();
 | 
					    auto pid = fork();
 | 
				
			||||||
    if (pid < 0) {
 | 
					    if (pid < 0) {
 | 
				
			||||||
      exit(1);
 | 
					      exit(1);
 | 
				
			||||||
@@ -769,10 +784,8 @@ auto handlers::launch_process(provider_type prov, std::string_view name,
 | 
				
			|||||||
    return {};
 | 
					    return {};
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  boost::process::v1::ipstream out;
 | 
					  bp1::ipstream out;
 | 
				
			||||||
  boost::process::v1::child proc(repertory_binary_,
 | 
					  bp1::child proc(repertory_binary_, bp1::args(args), bp1::std_out > out);
 | 
				
			||||||
                                 boost::process::v1::args(args),
 | 
					 | 
				
			||||||
                                 boost::process::v1::std_out > out);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  std::string data;
 | 
					  std::string data;
 | 
				
			||||||
  std::string line;
 | 
					  std::string line;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user