2.0.0-rc (#9)
Some checks failed
BlockStorage/repertory_osx/pipeline/head This commit looks good
BlockStorage/repertory_windows/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/head There was a failure building this commit
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good
BlockStorage/repertory_osx_builds/pipeline/head There was a failure building this commit

### Issues

* \#1 \[bug\] Unable to mount S3 due to 'item_not_found' exception
* \#2 Require bucket name for S3 mounts
* \#3 \[bug\] File size is not being updated in S3 mount
* \#4 Upgrade to libfuse-3.x.x
* \#5 Switch to renterd for Sia support
* \#6 Switch to cpp-httplib to further reduce dependencies
* \#7 Remove global_data and calculate used disk space per provider
* \#8 Switch to libcurl for S3 mount support

### Changes from v1.x.x

* Added read-only encrypt provider
  * Pass-through mount point that transparently encrypts source data using `XChaCha20-Poly1305`
* Added S3 encryption support via `XChaCha20-Poly1305`
* Added replay protection to remote mounts
* Added support base64 writes in remote FUSE
* Created static linked Linux binaries for `amd64` and `aarch64` using `musl-libc`
* Removed legacy Sia renter support
* Removed Skynet support
* Fixed multiple remote mount WinFSP API issues on \*NIX servers
* Implemented chunked read and write
  * Writes for non-cached files are performed in chunks of 8Mib
* Removed `repertory-ui` support
* Removed `FreeBSD` support
* Switched to `libsodium` over `CryptoPP`
* Switched to `XChaCha20-Poly1305` for remote mounts
* Updated `GoogleTest` to v1.14.0
* Updated `JSON for Modern C++` to v3.11.2
* Updated `OpenSSL` to v1.1.1w
* Updated `RocksDB` to v8.5.3
* Updated `WinFSP` to 2023
* Updated `boost` to v1.78.0
* Updated `cURL` to v8.3.0
* Updated `zlib` to v1.3
* Use `upload_manager` for all providers
  * Adds a delay to uploads to prevent excessive API calls
  * Supports re-upload after mount restart for incomplete uploads
  * NOTE: Uploads for all providers are full file (no resume support)
    * Multipart upload support is planned for S3

Reviewed-on: #9
This commit is contained in:
2023-10-29 06:55:59 +00:00
parent 3ff46723b8
commit f43c41f88a
839 changed files with 98214 additions and 92959 deletions

View File

@ -1,91 +1,95 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_ACTIONS_HPP_
#define INCLUDE_CLI_ACTIONS_HPP_
#include "common.hpp"
#include "cli/check_version.hpp"
#include "cli/create_directory.hpp"
#include "cli/display_config.hpp"
#include "cli/drive_information.hpp"
#include "cli/export.hpp"
#include "cli/export_all.hpp"
#include "cli/get.hpp"
#include "cli/get_directory_items.hpp"
#include "cli/get_pinned_files.hpp"
#include "cli/help.hpp"
#include "cli/import.hpp"
#include "cli/import_json.hpp"
#include "cli/list_objects.hpp"
#include "cli/mount.hpp"
#include "cli/open_files.hpp"
#include "cli/pin_file.hpp"
#include "cli/pinned_status.hpp"
#include "cli/set.hpp"
#include "cli/status.hpp"
#include "cli/test_skynet_auth.hpp"
#include "cli/unmount.hpp"
#include "cli/unpin_file.hpp"
#include "cli/version.hpp"
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
typedef std::function<exit_code(const int &argc, char *argv[], const std::string &data_directory,
const provider_type &pt, const std::string &unique_id,
std::string user, std::string password)>
action;
using action = std::function<exit_code(
int, char **, const std::string &, const provider_type &,
const std::string &, std::string, std::string)>;
struct option_hasher {
std::size_t operator()(const utils::cli::option &opt) const {
auto operator()(const utils::cli::option &opt) const -> std::size_t {
return std::hash<std::string>()(opt[0u] + '|' + opt[1u]);
}
};
static const std::unordered_map<utils::cli::option, action, option_hasher> option_actions = {
{utils::cli::options::check_version_option, cli::actions::check_version},
{utils::cli::options::display_config_option, cli::actions::display_config},
{utils::cli::options::drive_information_option, cli::actions::drive_information},
{utils::cli::options::export_option, cli::actions::export_action},
{utils::cli::options::export_all_option, cli::actions::export_all},
{utils::cli::options::get_directory_items_option, cli::actions::get_directory_items},
{utils::cli::options::get_option, cli::actions::get},
{utils::cli::options::get_pinned_files_option, cli::actions::get_pinned_files},
{utils::cli::options::import_option, cli::actions::import},
{utils::cli::options::import_json_option, cli::actions::import_json},
{utils::cli::options::open_files_option, cli::actions::open_files},
{utils::cli::options::pin_file_option, cli::actions::pin_file},
{utils::cli::options::pinned_status_option, cli::actions::pinned_status},
{utils::cli::options::set_option, cli::actions::set},
{utils::cli::options::status_option, cli::actions::status},
#if defined(REPERTORY_ENABLE_SKYNET)
{utils::cli::options::test_skynet_auth_option, cli::actions::test_skynet_auth},
static const std::unordered_map<utils::cli::option, action, option_hasher>
option_actions = {
{utils::cli::options::check_version_option,
cli::actions::check_version},
#if defined(REPERTORY_ENABLE_S3)
{utils::cli::options::create_directory_option,
cli::actions::create_directory},
{utils::cli::options::list_objects_option, cli::actions::list_objects},
#endif
{utils::cli::options::unmount_option, cli::actions::unmount},
{utils::cli::options::unpin_file_option, cli::actions::unpin_file},
{utils::cli::options::display_config_option,
cli::actions::display_config},
{utils::cli::options::drive_information_option,
cli::actions::drive_information},
{utils::cli::options::get_directory_items_option,
cli::actions::get_directory_items},
{utils::cli::options::get_option, cli::actions::get},
{utils::cli::options::get_pinned_files_option,
cli::actions::get_pinned_files},
{utils::cli::options::open_files_option, cli::actions::open_files},
{utils::cli::options::pin_file_option, cli::actions::pin_file},
{utils::cli::options::pinned_status_option,
cli::actions::pinned_status},
{utils::cli::options::set_option, cli::actions::set},
{utils::cli::options::status_option, cli::actions::status},
{utils::cli::options::unmount_option, cli::actions::unmount},
{utils::cli::options::unpin_file_option, cli::actions::unpin_file},
};
static exit_code perform_action(const utils::cli::option &opt, const int &argc, char *argv[],
const std::string &data_directory, const provider_type &pt,
const std::string &unique_id, std::string user,
std::string password) {
[[nodiscard]] inline auto
perform_action(const utils::cli::option &opt, int argc, char *argv[],
const std::string &data_directory, const provider_type &pt,
const std::string &unique_id, std::string user,
std::string password) -> exit_code {
if (utils::cli::has_option(argc, argv, opt)) {
if (option_actions.find(opt) != option_actions.end()) {
return option_actions.at(opt)(argc, argv, data_directory, pt, unique_id, std::move(user),
std::move(password));
return option_actions.at(opt)(argc, argv, data_directory, pt, unique_id,
user, password);
}
}

View File

@ -1,60 +1,69 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_CHECK_VERSION_HPP_
#define INCLUDE_CLI_CHECK_VERSION_HPP_
#include "common.hpp"
#include "comm/curl/curl_comm.hpp"
#include "app_config.hpp"
#include "types/repertory.hpp"
namespace repertory::cli::actions {
static exit_code check_version(const int &, char *[], const std::string &data_directory,
const provider_type &pt, const std::string &, std::string,
std::string) {
[[nodiscard]] inline auto
check_version(int, char *[], const std::string & /* data_directory */,
const provider_type & /* pt */, const std::string &, std::string,
std::string) -> exit_code {
auto ret = exit_code::success;
if (not((pt == provider_type::remote) || (pt == provider_type::s3) ||
(pt == provider_type::skynet))) {
app_config config(pt, data_directory);
curl_comm comm(config);
json data, err;
if (comm.get("/daemon/version", data, err) == api_error::success) {
const auto res = utils::compare_version_strings(data["version"].get<std::string>(),
app_config::get_provider_minimum_version(pt));
if (res < 0) {
ret = exit_code::incompatible_version;
std::cerr << "Failed!" << std::endl;
std::cerr << " Actual: " << data["version"].get<std::string>() << std::endl;
std::cerr << " Minimum: " << app_config::get_provider_minimum_version(pt) << std::endl;
} else {
std::cout << "Success!" << std::endl;
std::cout << " Actual: " << data["version"].get<std::string>() << std::endl;
std::cout << " Minimum: " << app_config::get_provider_minimum_version(pt) << std::endl;
}
} else {
std::cerr << "Failed!" << std::endl;
std::cerr << err.dump(2) << std::endl;
ret = exit_code::communication_error;
}
}
// TODO need to updated way to check version
// if (not((pt == provider_type::remote) || (pt == provider_type::s3))) {
// app_config config(pt, data_directory);
// curl_comm comm(config);
// json data, err;
//
// if (comm.get("/daemon/version", data, err) == api_error::success) {
// const auto res = utils::compare_version_strings(
// data["version"].get<std::string>(),
// app_config::get_provider_minimum_version(pt));
// if (res < 0) {
// ret = exit_code::incompatible_version;
// std::cerr << "Failed!" << std::endl;
// std::cerr << " Actual: " << data["version"].get<std::string>()
// << std::endl;
// std::cerr << " Minimum: "
// << app_config::get_provider_minimum_version(pt) <<
// std::endl;
// } else {
// std::cout << "Success!" << std::endl;
// std::cout << " Actual: " << data["version"].get<std::string>()
// << std::endl;
// std::cout << " Minimum: "
// << app_config::get_provider_minimum_version(pt) <<
// std::endl;
// }
// } else {
// std::cerr << "Failed!" << std::endl;
// std::cerr << err.dump(2) << std::endl;
// ret = exit_code::communication_error;
// }
// }
return ret;
}

View File

@ -0,0 +1,80 @@
/*
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_CREATE_DIRECTORY_HPP_
#define INCLUDE_CLI_CREATE_DIRECTORY_HPP_
#if defined(REPERTORY_ENABLE_S3)
#include "app_config.hpp"
#include "comm/s3/s3_comm.hpp"
#include "platform/platform.hpp"
#include "providers/i_provider.hpp"
#include "providers/provider.hpp"
#include "rpc/client/client.hpp"
#include "types/repertory.hpp"
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
[[nodiscard]] inline auto
create_directory(int argc, char *argv[], const std::string &data_directory,
const provider_type &pt, const std::string &unique_id,
std::string /* user */, std::string /* password */)
-> exit_code {
auto ret = exit_code::invalid_provider_type;
if (pt == provider_type::s3) {
std::string api_path;
if ((ret = utils::cli::parse_string_option(
argc, argv, utils::cli::options::create_directory_option,
api_path)) == exit_code::success) {
lock_data lock(pt, unique_id);
const auto res = lock.grab_lock(1u);
/* if (res == lock_result::locked) { */
/* auto port = app_config::default_api_port(pt); */
/* utils::cli::get_api_authentication_data(user, password, port, pt,
* data_directory); */
/* const auto response = */
/* client({"localhost", password, port,
* user}).create_directory(api_path); */
/* std::cout << static_cast<int>(response.response_type) << std::endl; */
/* std::cout << response.data.dump(2) << std::endl; */
/* } else */
if (res == lock_result::success) {
std::cout << "creating directory: '" << api_path << "'" << std::endl;
app_config config(pt, data_directory);
s3_comm comm(config);
const auto res = comm.create_directory(api_path);
std::cout << api_error_to_string(res) << std::endl;
ret = exit_code::success;
} else {
std::cout << "failed to grab lock: '" << static_cast<int>(res) << "'"
<< std::endl;
ret = exit_code::lock_failed;
}
}
}
return ret;
}
} // namespace repertory::cli::actions
#endif // REPERTORY_ENABLE_S3
#endif // INCLUDE_CLI_CREATE_DIRECTORY_HPP_

View File

@ -1,25 +1,27 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_DISPLAY_CONFIG_HPP_
#define INCLUDE_CLI_DISPLAY_CONFIG_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "platform/platform.hpp"
#include "rpc/client/client.hpp"
@ -28,9 +30,10 @@
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code display_config(const int &, char *[], const std::string &data_directory,
const provider_type &pt, const std::string &unique_id,
std::string user, std::string password) {
[[nodiscard]] inline auto
display_config(int, char *[], const std::string &data_directory,
const provider_type &pt, const std::string &unique_id,
std::string user, std::string password) -> exit_code {
lock_data lock(pt, unique_id);
const auto res = lock.grab_lock(1u);
if (res == lock_result::success) {
@ -40,8 +43,10 @@ static exit_code display_config(const int &, char *[], const std::string &data_d
std::cout << cfg.dump(2) << std::endl;
} else if (res == lock_result::locked) {
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response = client({"localhost", password, port, user}).get_config();
utils::cli::get_api_authentication_data(user, password, port, pt,
data_directory);
const auto response =
client({"localhost", password, port, user}).get_config();
std::cout << static_cast<int>(response.response_type) << std::endl;
std::cout << response.data.dump(2) << std::endl;
}

View File

@ -1,25 +1,27 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_DRIVE_INFORMATION_HPP_
#define INCLUDE_CLI_DRIVE_INFORMATION_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "platform/platform.hpp"
#include "rpc/client/client.hpp"
@ -28,21 +30,25 @@
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code drive_information(const int &, char *[], const std::string &data_directory,
const provider_type &pt, const std::string &unique_id,
std::string user, std::string password) {
[[nodiscard]] inline auto
drive_information(int, char *[], const std::string &data_directory,
const provider_type &pt, const std::string &unique_id,
std::string user, std::string password) -> exit_code {
auto ret = exit_code::success;
lock_data lock(pt, unique_id);
const auto res = lock.grab_lock(1u);
if (res == lock_result::locked) {
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response = client({"localhost", password, port, user}).get_drive_information();
utils::cli::get_api_authentication_data(user, password, port, pt,
data_directory);
const auto response =
client({"localhost", password, port, user}).get_drive_information();
std::cout << static_cast<int>(response.response_type) << std::endl;
std::cout << response.data.dump(2) << std::endl;
} else {
std::cerr << app_config::get_provider_display_name(pt) << " is not mounted." << std::endl;
std::cerr << app_config::get_provider_display_name(pt) << " is not mounted."
<< std::endl;
ret = exit_code::not_mounted;
}

View File

@ -1,53 +0,0 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef INCLUDE_CLI_EXPORT_HPP_
#define INCLUDE_CLI_EXPORT_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "rpc/client/client.hpp"
#include "types/repertory.hpp"
#include "types/rpc.hpp"
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code export_action(const int &argc, char *argv[], const std::string &data_directory,
const provider_type &pt, const std::string &, std::string user,
std::string password) {
std::string data;
auto ret = utils::cli::parse_string_option(argc, argv,
repertory::utils::cli::options::export_option, data);
if (ret == exit_code::success) {
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response =
client({"localhost", password, port, user}).export_list(utils::string::split(data, ','));
if (response.response_type == rpc_response_type::success) {
std::cout << response.data.dump(2) << std::endl;
} else {
std::cerr << response.data.dump(2) << std::endl;
ret = exit_code::export_failed;
}
}
return ret;
}
} // namespace repertory::cli::actions
#endif // INCLUDE_CLI_EXPORT_HPP_

View File

@ -1,49 +0,0 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef INCLUDE_CLI_EXPORT_ALL_HPP_
#define INCLUDE_CLI_EXPORT_ALL_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "rpc/client/client.hpp"
#include "types/repertory.hpp"
#include "types/rpc.hpp"
#include "types/skynet.hpp"
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code export_all(const int &, char *[], const std::string &data_directory,
const provider_type &pt, const std::string &, std::string user,
std::string password) {
auto ret = exit_code::success;
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response = client({"localhost", password, port, user}).export_all();
if (response.response_type == rpc_response_type::success) {
std::cout << response.data.dump(2) << std::endl;
} else {
std::cerr << response.data.dump(2) << std::endl;
ret = exit_code::export_failed;
}
return ret;
}
} // namespace repertory::cli::actions
#endif // INCLUDE_CLI_EXPORT_ALL_HPP_

View File

@ -1,25 +1,27 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_GET_HPP_
#define INCLUDE_CLI_GET_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "platform/platform.hpp"
#include "rpc/client/client.hpp"
@ -28,26 +30,32 @@
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code get(const int &argc, char *argv[], const std::string &data_directory,
const provider_type &pt, const std::string &unique_id, std::string user,
std::string password) {
[[nodiscard]] inline auto get(int argc, char *argv[],
const std::string &data_directory,
const provider_type &pt,
const std::string &unique_id, std::string user,
std::string password) -> exit_code {
std::string data;
auto ret =
utils::cli::parse_string_option(argc, argv, repertory::utils::cli::options::get_option, data);
auto ret = utils::cli::parse_string_option(
argc, argv, repertory::utils::cli::options::get_option, data);
if (ret == exit_code::success) {
lock_data lock(pt, unique_id);
const auto res = lock.grab_lock(1);
if (res == lock_result::success) {
app_config config(pt, data_directory);
const auto value = config.get_value_by_name(data);
std::cout << (value.empty() ? static_cast<int>(rpc_response_type::config_value_not_found) : 0)
std::cout << (value.empty()
? static_cast<int>(
rpc_response_type::config_value_not_found)
: 0)
<< std::endl;
std::cout << json({{"value", value}}).dump(2) << std::endl;
} else if (res == lock_result::locked) {
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response =
client({"localhost", password, port, user}).get_config_value_by_name(data);
utils::cli::get_api_authentication_data(user, password, port, pt,
data_directory);
const auto response = client({"localhost", password, port, user})
.get_config_value_by_name(data);
std::cout << static_cast<int>(response.response_type) << std::endl;
std::cout << response.data.dump(2) << std::endl;
}

View File

@ -1,43 +1,48 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_GET_DIRECTORY_ITEMS_HPP_
#define INCLUDE_CLI_GET_DIRECTORY_ITEMS_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "rpc/client/client.hpp"
#include "types/repertory.hpp"
#include "types/rpc.hpp"
#include "types/skynet.hpp"
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code get_directory_items(const int &argc, char *argv[],
const std::string &data_directory, const provider_type &pt,
const std::string &, std::string user, std::string password) {
[[nodiscard]] inline auto
get_directory_items(int argc, char *argv[], const std::string &data_directory,
const provider_type &pt, const std::string &,
std::string user, std::string password) -> exit_code {
std::string data;
auto ret = utils::cli::parse_string_option(
argc, argv, repertory::utils::cli::options::get_directory_items_option, data);
argc, argv, repertory::utils::cli::options::get_directory_items_option,
data);
if (ret == exit_code::success) {
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response = client({"localhost", password, port, user}).get_directory_items(data);
utils::cli::get_api_authentication_data(user, password, port, pt,
data_directory);
const auto response =
client({"localhost", password, port, user}).get_directory_items(data);
if (response.response_type == rpc_response_type::success) {
std::cout << response.data.dump(2) << std::endl;
} else {

View File

@ -1,25 +1,27 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_GET_PINNED_FILES_HPP_
#define INCLUDE_CLI_GET_PINNED_FILES_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "rpc/client/client.hpp"
#include "types/repertory.hpp"
@ -27,13 +29,16 @@
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code get_pinned_files(const int &, char *[], const std::string &data_directory,
const provider_type &pt, const std::string &, std::string user,
std::string password) {
[[nodiscard]] inline auto
get_pinned_files(int, char *[], const std::string &data_directory,
const provider_type &pt, const std::string &, std::string user,
std::string password) -> exit_code {
auto ret = exit_code::success;
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response = client({"localhost", password, port, user}).get_pinned_files();
utils::cli::get_api_authentication_data(user, password, port, pt,
data_directory);
const auto response =
client({"localhost", password, port, user}).get_pinned_files();
if (response.response_type == rpc_response_type::success) {
std::cout << response.data.dump(2) << std::endl;
} else {

View File

@ -1,105 +1,99 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_HELP_HPP_
#define INCLUDE_CLI_HELP_HPP_
#include "common.hpp"
namespace repertory::cli::actions {
template <typename drive> static void help(const int &argc, char *argv[]) {
template <typename drive> inline void help(int argc, char *argv[]) {
drive::display_options(argc, argv);
std::cout << "Repertory options:" << std::endl;
std::cout << " -cv,--check_version Check daemon version compatibility"
std::cout << " -cv,--check_version Check daemon version "
"compatibility"
<< std::endl;
std::cout << " -dc,--display_config Display configuration" << std::endl;
std::cout << " -dd,--data_directory [directory] Override data directory" << std::endl;
std::cout << " -di,--drive_information Display mounted drive information"
std::cout << " -dc,--display_config Display configuration"
<< std::endl;
#if defined(REPERTORY_ENABLE_SKYNET)
std::cout << " -ea,--export_all Export all Skynet skylinks" << std::endl;
std::cout << " -ex,--export [path1,path2,...] Export one or more Skynet skylinks"
std::cout << " -dd,--data_directory [directory] Override data directory"
<< std::endl;
std::cout << " -di,--drive_information Display mounted drive "
"information"
<< std::endl;
#endif // defined(REPERTORY_ENABLE_SKYNET)
#if defined(REPERTORY_ENABLE_S3)
std::cout << " -s3,--s3 Enables S3 mode" << std::endl;
std::cout << " -na,--name Unique name for S3 instance [Required]"
std::cout << " -s3,--s3 Enables S3 mode"
<< std::endl;
std::cout << " -na,--name Unique name for S3 "
"instance [Required]"
<< std::endl;
std::cout
<< " -cd,--create_directory [API path] Create directory object in S3"
<< std::endl;
std::cout << " -lo,--list_objects List all S3 objects"
<< std::endl;
#endif // defined(REPERTORY_ENABLE_S3)
std::cout << " -gc,--generate_config Generate initial configuration" << std::endl;
std::cout << " -get,--get [name] Get configuration value" << std::endl;
std::cout << " -gdi,--get_directory_items Get directory list in json format"
std::cout
<< " -gc,--generate_config Generate initial configuration"
<< std::endl;
std::cout << " -get,--get [name] Get configuration value"
<< std::endl;
std::cout << " -gdi,--get_directory_items Get directory list in "
"json format"
<< std::endl
<< " [API path]" << std::endl;
std::cout << " -gpf,--get_pinned_files Get a list of all pinned files" << std::endl;
std::cout << " -gt,--generate_template Generate configuration template" << std::endl;
#if defined(REPERTORY_ENABLE_SKYNET)
std::cout << " -ij,--import_json [json_array] Import Skynet skylink(s)" << std::endl;
std::cout << " [json_array] format:" << std::endl;
std::cout << " [{" << std::endl;
std::cout << R"( "directory": "/parent",)" << std::endl;
std::cout << R"( "skylink": "AACeCiD6WQG6DzDcCdIu3cFPSxMUMoQPx46NYSyijNMKUA",)"
std::cout
<< " -gpf,--get_pinned_files Get a list of all pinned files"
<< std::endl;
std::cout
<< " -nc Force disable console output"
<< std::endl;
std::cout
<< " -of,--open_files List all open files and count"
<< std::endl;
std::cout << " -rm,--remote_mount [host/ip:port] Enables remote mount mode"
<< std::endl;
std::cout << R"( "token": "encryption password")" << std::endl;
std::cout << " }]" << std::endl;
std::cout << " NOTE: 'directory' and 'token' are optional" << std::endl;
std::cout << " -im,--import [list] Import Skynet skylink(s)" << std::endl;
std::cout << " [list] format:" << std::endl;
std::cout << " directory=<directory>:skylink=<skylink>:token=<token>;..." << std::endl;
std::cout << std::endl;
std::cout << " NOTE: 'directory' and 'token' are optional" << std::endl;
std::cout << " NOTE: Use '@sem@' to escape a ';'" << std::endl;
std::cout << " Use '@comma@' to escape a ','" << std::endl;
std::cout << " Use '@equal@' to escape an '='" << std::endl;
std::cout << " Use '@dbl_quote@' to escape a '\"'" << std::endl;
#endif // defined(REPERTORY_ENABLE_SKYNET)
std::cout << " -nc Force disable console output" << std::endl;
std::cout << " -of,--open_files List all open files and count" << std::endl;
std::cout << " -rm,--remote_mount [host/ip:port] Enables remote mount mode" << std::endl;
std::cout << " -pf,--pin_file [API path] Pin a file to cache to prevent eviction"
std::cout << " -pf,--pin_file [API path] Pin a file to cache to "
"prevent eviction"
<< std::endl;
std::cout << " -ps,--pinned_status [API path] Return pinned status for a file" << std::endl;
std::cout << " -pw,--password Specify API password" << std::endl;
#if defined(REPERTORY_ENABLE_SKYNET)
std::cout << " -sk,--skynet [EXPERIMENTAL] Enables Skynet mode"
std::cout
<< " -ps,--pinned_status [API path] Return pinned status for a file"
<< std::endl;
std::cout << " -pw,--password Specify API password"
<< std::endl;
#endif // defined(REPERTORY_ENABLE_SKYNET)
#ifndef _WIN32
#if defined(REPERTORY_ENABLE_S3)
std::cout << " -o s3 Enables S3 mode for 'fstab' mounts"
std::cout << " -o s3 Enables S3 mode for "
"'fstab' mounts"
<< std::endl;
#endif // defined(REPERTORY_ENABLE_S3)
#if defined(REPERTORY_ENABLE_SKYNET)
std::cout << " -o sk,-o skynet Enables Skynet mode for 'fstab' mounts"
<< std::endl;
#endif // defined(REPERTORY_ENABLE_SKYNET)
#endif // _WIN32
std::cout << " -set,--set [name] [value] Set configuration value" << std::endl;
std::cout << " -status Display mount status" << std::endl;
#if defined(REPERTORY_ENABLE_SKYNET)
std::cout << " -tsa,--test_skynet_auth Test Skynet portal authentication"
std::cout << " -set,--set [name] [value] Set configuration value"
<< std::endl;
std::cout << " [URL] [user] [password] [agent string] [API key]" << std::endl;
#endif // defined(REPERTORY_ENABLE_SKYNET)
std::cout << " -unmount,--unmount Unmount and shutdown" << std::endl;
std::cout << " -uf,--unpin_file [API path] Unpin a file from cache to allow eviction"
std::cout << " -status Display mount status"
<< std::endl;
std::cout << " -unmount,--unmount Unmount and shutdown"
<< std::endl;
std::cout << " -uf,--unpin_file [API path] Unpin a file from cache "
"to allow eviction"
<< std::endl;
std::cout << " -us,--user Specify API user name"
<< std::endl;
std::cout << " -us,--user Specify API user name" << std::endl;
}
} // namespace repertory::cli::actions

View File

@ -1,62 +0,0 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef INCLUDE_CLI_IMPORT_HPP_
#define INCLUDE_CLI_IMPORT_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "rpc/client/client.hpp"
#include "types/repertory.hpp"
#include "types/rpc.hpp"
#include "types/skynet.hpp"
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code import(const int &argc, char *argv[], const std::string &data_directory,
const provider_type &pt, const std::string &, std::string user,
std::string password) {
std::string data;
auto ret = utils::cli::parse_string_option(argc, argv,
repertory::utils::cli::options::import_option, data);
if (ret == exit_code::success) {
utils::string::replace(data, "@dbl_quote@", "\"");
const auto parts = utils::string::split(data, ';');
skylink_import_list list;
for (const auto &part : parts) {
list.emplace_back(
skylink_import::from_string(utils::string::replace_copy(part, "@sem@", ";")));
}
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response = client({"localhost", password, port, user}).import_skylink(list);
std::cout << static_cast<int>(response.response_type) << std::endl;
if (response.response_type == rpc_response_type::success) {
std::cout << response.data.dump(2) << std::endl;
} else {
std::cerr << response.data.dump(2) << std::endl;
ret = exit_code::import_failed;
}
}
return ret;
}
} // namespace repertory::cli::actions
#endif // INCLUDE_CLI_IMPORT_HPP_

View File

@ -1,68 +0,0 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef INCLUDE_CLI_IMPORT_JSON_HPP_
#define INCLUDE_CLI_IMPORT_JSON_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "rpc/client/client.hpp"
#include "types/repertory.hpp"
#include "types/rpc.hpp"
#include "types/skynet.hpp"
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code import_json(const int &argc, char *argv[], const std::string &data_directory,
const provider_type &pt, const std::string &, std::string user,
std::string password) {
std::string data;
auto ret = utils::cli::parse_string_option(argc, argv, {"-ij", "--import_json"}, data);
if (ret == exit_code::success) {
utils::string::replace(data, "@dbl_quote@", "\"");
skylink_import_list list;
try {
const auto json_data = json::parse(data);
for (const auto &j : json_data) {
list.emplace_back(skylink_import::from_json(j));
}
} catch (const std::exception &e) {
std::cerr << "Import JSON failed:" << std::endl << e.what() << std::endl;
ret = exit_code::import_failed;
}
if (not list.empty()) {
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response = client({"localhost", password, port, user}).import_skylink(list);
std::cout << static_cast<int>(response.response_type) << std::endl;
if (response.response_type == rpc_response_type::success) {
std::cout << response.data.dump(2) << std::endl;
} else {
std::cerr << response.data.dump(2) << std::endl;
ret = exit_code::import_failed;
}
}
}
return ret;
}
} // namespace repertory::cli::actions
#endif // INCLUDE_CLI_IMPORT_JSON_HPP_

View File

@ -0,0 +1,81 @@
/*
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_LIST_OBJECTS_HPP_
#define INCLUDE_CLI_LIST_OBJECTS_HPP_
#if defined(REPERTORY_ENABLE_S3)
#include "app_config.hpp"
#include "comm/s3/s3_comm.hpp"
#include "platform/platform.hpp"
#include "providers/i_provider.hpp"
#include "providers/provider.hpp"
#include "rpc/client/client.hpp"
#include "types/repertory.hpp"
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
[[nodiscard]] inline auto
list_objects(int /* argc */, char * /* argv */[],
const std::string &data_directory, const provider_type &pt,
const std::string &unique_id, std::string /* user */,
std::string /* password */) -> exit_code {
auto ret = exit_code::invalid_provider_type;
if (pt == provider_type::s3) {
lock_data lock(pt, unique_id);
const auto res = lock.grab_lock(1u);
/* if (res == lock_result::locked) { */
/* auto port = app_config::default_api_port(pt); */
/* utils::cli::get_api_authentication_data(user, password, port, pt,
* data_directory); */
/* const auto response = */
/* client({"localhost", password, port,
* user}).create_directory(api_path); */
/* std::cout << static_cast<int>(response.response_type) << std::endl; */
/* std::cout << response.data.dump(2) << std::endl; */
/* } else */
if (res == lock_result::success) {
app_config config(pt, data_directory);
s3_comm comm(config);
std::vector<directory_item> list{};
const auto res = comm.get_object_list(list);
if (res == api_error::success) {
for (const auto &di : list) {
std::cout << di.to_json().dump(2) << std::endl;
}
ret = exit_code::success;
} else {
std::cout << api_error_to_string(res) << std::endl;
}
} else {
std::cout << "failed to grab lock: '" << static_cast<int>(res) << "'"
<< std::endl;
ret = exit_code::lock_failed;
}
}
return ret;
}
} // namespace repertory::cli::actions
#endif // REPERTORY_ENABLE_S3
#endif // INCLUDE_CLI_LIST_OBJECTS_HPP_

View File

@ -1,153 +1,173 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_MOUNT_HPP_
#define INCLUDE_CLI_MOUNT_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "platform/platform.hpp"
#include "providers/i_provider.hpp"
#include "providers/provider.hpp"
#include "types/repertory.hpp"
#include "utils/cli_utils.hpp"
#include "utils/com_init_wrapper.hpp"
#include "utils/file_utils.hpp"
#include "utils/string_utils.hpp"
#ifdef _WIN32
#include "drives/winfsp/remotewinfsp/remote_client.hpp"
#include "drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp"
#include "drives/winfsp/winfsp_drive.hpp"
typedef repertory::winfsp_drive repertory_drive;
typedef repertory::remote_winfsp::remote_client remote_client;
typedef repertory::remote_winfsp::remote_winfsp_drive remote_drive;
typedef repertory::remote_winfsp::i_remote_instance remote_instance;
using repertory_drive = repertory::winfsp_drive;
using remote_client = repertory::remote_winfsp::remote_client;
using remote_drive = repertory::remote_winfsp::remote_winfsp_drive;
using remote_instance = repertory::remote_winfsp::i_remote_instance;
#else
#include "drives/fuse/fuse_drive.hpp"
#include "drives/fuse/remotefuse/remote_client.hpp"
#include "drives/fuse/remotefuse/remote_fuse_drive.hpp"
typedef repertory::fuse_drive repertory_drive;
typedef repertory::remote_fuse::remote_client remote_client;
typedef repertory::remote_fuse::remote_fuse_drive remote_drive;
typedef repertory::remote_fuse::i_remote_instance remote_instance;
using repertory_drive = repertory::fuse_drive;
using remote_client = repertory::remote_fuse::remote_client;
using remote_drive = repertory::remote_fuse::remote_fuse_drive;
using remote_instance = repertory::remote_fuse::i_remote_instance;
#endif
namespace repertory::cli::actions {
static exit_code mount(const int &argc, char *argv[], std::string data_directory, int &mount_result,
provider_type pt, const std::string &remote_host,
const std::uint16_t &remote_port, const std::string &unique_id) {
[[nodiscard]] inline auto
mount(int argc, char *argv[], std::string data_directory, int &mount_result,
provider_type pt, const std::string &remote_host,
std::uint16_t remote_port, const std::string &unique_id) -> exit_code {
auto ret = exit_code::success;
lock_data lock(pt, unique_id);
const auto res = lock.grab_lock();
if (res == lock_result::locked) {
ret = exit_code::mount_active;
std::cerr << app_config::get_provider_display_name(pt) << " mount is already active"
<< std::endl;
std::cerr << app_config::get_provider_display_name(pt)
<< " mount is already active" << std::endl;
} else if (res == lock_result::success) {
curl_global_init(CURL_GLOBAL_DEFAULT);
{
const auto generate_config =
utils::cli::has_option(argc, argv, utils::cli::options::generate_config_option);
if (generate_config) {
app_config config(pt, data_directory);
if (pt == provider_type::remote) {
config.set_enable_remote_mount(false);
config.set_is_remote_mount(true);
const auto generate_config = utils::cli::has_option(
argc, argv, utils::cli::options::generate_config_option);
if (generate_config) {
app_config config(pt, data_directory);
if (pt == provider_type::remote) {
config.set_enable_remote_mount(false);
config.set_is_remote_mount(true);
config.set_remote_host_name_or_ip(remote_host);
config.set_remote_port(remote_port);
config.save();
}
std::cout << "Generated " << app_config::get_provider_display_name(pt)
<< " Configuration" << std::endl;
std::cout << config.get_config_file_path() << std::endl;
ret = utils::file::is_file(config.get_config_file_path())
? exit_code::success
: exit_code::file_creation_failed;
} else {
#ifdef _WIN32
if (utils::cli::has_option(argc, argv,
utils::cli::options::hidden_option)) {
::ShowWindow(::GetConsoleWindow(), SW_HIDE);
}
#endif
const auto drive_args =
utils::cli::parse_drive_options(argc, argv, pt, data_directory);
app_config config(pt, data_directory);
#ifdef _WIN32
if (config.get_enable_mount_manager() &&
not utils::is_process_elevated()) {
com_init_wrapper cw;
if (not lock.set_mount_state(true, "elevating", -1)) {
std::cerr << "failed to set mount state" << std::endl;
}
lock.release();
mount_result = utils::run_process_elevated(argc, argv);
lock_data lock2(pt, unique_id);
if (lock2.grab_lock() == lock_result::success) {
if (not lock2.set_mount_state(false, "", -1)) {
std::cerr << "failed to set mount state" << std::endl;
}
lock2.release();
}
return exit_code::mount_result;
}
#endif
std::cout << "Initializing " << app_config::get_provider_display_name(pt)
<< (unique_id.empty() ? ""
: (pt == provider_type::s3)
? " [" + unique_id + ']'
: " [" + remote_host + ':' +
std::to_string(remote_port) + ']')
<< " Drive" << std::endl;
if (pt == provider_type::remote) {
std::uint16_t port = 0u;
if (utils::get_next_available_port(config.get_api_port(), port)) {
config.set_remote_host_name_or_ip(remote_host);
config.set_remote_port(remote_port);
}
std::cout << "Generated " << app_config::get_provider_display_name(pt) << " Configuration"
<< std::endl;
std::cout << config.get_config_file_path() << std::endl;
ret = utils::file::is_file(config.get_config_file_path()) ? exit_code::success
: exit_code::file_creation_failed;
} else {
#ifdef _WIN32
if (utils::cli::has_option(argc, argv, utils::cli::options::hidden_option)) {
::ShowWindow(::GetConsoleWindow(), SW_HIDE);
}
#endif
const auto driveArgs = utils::cli::parse_drive_options(argc, argv, pt, data_directory);
std::cout << "Initializing " << app_config::get_provider_display_name(pt)
<< (unique_id.empty() ? ""
: (pt == provider_type::s3)
? " [" + unique_id + ']'
: " [" + remote_host + ':' + std::to_string(remote_port) + ']')
<< " Drive" << std::endl;
app_config config(pt, data_directory);
if (pt == provider_type::remote) {
std::uint16_t port = 0u;
if (utils::get_next_available_port(config.get_api_port(), port)) {
config.set_remote_host_name_or_ip(remote_host);
config.set_remote_port(remote_port);
config.set_api_port(port);
config.set_is_remote_mount(true);
config.set_enable_remote_mount(false);
config.save();
try {
remote_drive drive(config, lock, [&config]() -> std::unique_ptr<remote_instance> {
return std::unique_ptr<remote_instance>(new remote_client(config));
});
lock.set_mount_state(true, "", -1);
mount_result = drive.mount(driveArgs);
ret = exit_code::mount_result;
} catch (const std::exception &e) {
std::cerr << "FATAL: " << e.what() << std::endl;
ret = exit_code::startup_exception;
}
} else {
std::cerr << "FATAL: Unable to get available port" << std::endl;
ret = exit_code::startup_exception;
}
} else {
#ifdef _WIN32
if (config.get_enable_mount_manager() && not utils::is_process_elevated()) {
com_init_wrapper cw;
lock.set_mount_state(true, "elevating", -1);
lock.release();
mount_result = utils::run_process_elevated(argc, argv);
lock_data lockData2(pt, unique_id);
if (lockData2.grab_lock() == lock_result::success) {
lockData2.set_mount_state(false, "", -1);
lockData2.release();
}
return exit_code::mount_result;
}
#endif
config.set_is_remote_mount(false);
config.set_api_port(port);
config.set_is_remote_mount(true);
config.set_enable_remote_mount(false);
config.save();
try {
auto provider = create_provider(pt, config);
repertory_drive drive(config, lock, *provider);
lock.set_mount_state(true, "", -1);
mount_result = drive.mount(driveArgs);
remote_drive drive(
config,
[&config]() -> std::unique_ptr<remote_instance> {
return std::unique_ptr<remote_instance>(
new remote_client(config));
},
lock);
if (not lock.set_mount_state(true, "", -1)) {
std::cerr << "failed to set mount state" << std::endl;
}
mount_result = drive.mount(drive_args);
ret = exit_code::mount_result;
} catch (const std::exception &e) {
std::cerr << "FATAL: " << e.what() << std::endl;
ret = exit_code::startup_exception;
}
} else {
std::cerr << "FATAL: Unable to get available port" << std::endl;
ret = exit_code::startup_exception;
}
} else {
config.set_is_remote_mount(false);
try {
auto provider = create_provider(pt, config);
repertory_drive drive(config, lock, *provider);
if (not lock.set_mount_state(true, "", -1)) {
std::cerr << "failed to set mount state" << std::endl;
}
mount_result = drive.mount(drive_args);
ret = exit_code::mount_result;
} catch (const std::exception &e) {
std::cerr << "FATAL: " << e.what() << std::endl;
ret = exit_code::startup_exception;
}
}
}
curl_global_cleanup();
} else {
ret = exit_code::lock_failed;
}

View File

@ -1,25 +1,27 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_OPEN_FILES_HPP_
#define INCLUDE_CLI_OPEN_FILES_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "platform/platform.hpp"
#include "rpc/client/client.hpp"
@ -28,20 +30,24 @@
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code open_files(const int &, char *[], const std::string &data_directory,
const provider_type &pt, const std::string &unique_id, std::string user,
std::string password) {
[[nodiscard]] inline auto
open_files(int, char *[], const std::string &data_directory,
const provider_type &pt, const std::string &unique_id,
std::string user, std::string password) -> exit_code {
auto ret = exit_code::success;
lock_data lock(pt, unique_id);
const auto res = lock.grab_lock(1u);
if (res == lock_result::locked) {
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response = client({"localhost", password, port, user}).get_open_files();
utils::cli::get_api_authentication_data(user, password, port, pt,
data_directory);
const auto response =
client({"localhost", password, port, user}).get_open_files();
std::cout << static_cast<int>(response.response_type) << std::endl;
std::cout << response.data.dump(2) << std::endl;
} else {
std::cerr << app_config::get_provider_display_name(pt) << " is not mounted." << std::endl;
std::cerr << app_config::get_provider_display_name(pt) << " is not mounted."
<< std::endl;
ret = exit_code::not_mounted;
}

View File

@ -1,43 +1,48 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_PIN_FILE_HPP_
#define INCLUDE_CLI_PIN_FILE_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "rpc/client/client.hpp"
#include "types/repertory.hpp"
#include "types/rpc.hpp"
#include "types/skynet.hpp"
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code pin_file(const int &argc, char *argv[], const std::string &data_directory,
const provider_type &pt, const std::string &, std::string user,
std::string password) {
[[nodiscard]] inline auto pin_file(int argc, char *argv[],
const std::string &data_directory,
const provider_type &pt, const std::string &,
std::string user, std::string password)
-> exit_code {
std::string data;
auto ret = utils::cli::parse_string_option(argc, argv,
repertory::utils::cli::options::pin_file_option, data);
auto ret = utils::cli::parse_string_option(
argc, argv, repertory::utils::cli::options::pin_file_option, data);
if (ret == exit_code::success) {
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response = client({"localhost", password, port, user}).pin_file(data);
utils::cli::get_api_authentication_data(user, password, port, pt,
data_directory);
const auto response =
client({"localhost", password, port, user}).pin_file(data);
if (response.response_type == rpc_response_type::success) {
std::cout << response.data.dump(2) << std::endl;
} else {

View File

@ -1,43 +1,48 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_PINNED_STATUS_HPP_
#define INCLUDE_CLI_PINNED_STATUS_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "rpc/client/client.hpp"
#include "types/repertory.hpp"
#include "types/rpc.hpp"
#include "types/skynet.hpp"
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code pinned_status(const int &argc, char *argv[], const std::string &data_directory,
const provider_type &pt, const std::string &, std::string user,
std::string password) {
[[nodiscard]] inline auto pinned_status(int argc, char *argv[],
const std::string &data_directory,
const provider_type &pt,
const std::string &, std::string user,
std::string password) -> exit_code {
std::string data;
auto ret = utils::cli::parse_string_option(
argc, argv, repertory::utils::cli::options::pinned_status_option, data);
if (ret == exit_code::success) {
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response = client({"localhost", password, port, user}).pinned_status(data);
utils::cli::get_api_authentication_data(user, password, port, pt,
data_directory);
const auto response =
client({"localhost", password, port, user}).pinned_status(data);
if (response.response_type == rpc_response_type::success) {
std::cout << response.data.dump(2) << std::endl;
} else {

View File

@ -1,25 +1,27 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_SET_HPP_
#define INCLUDE_CLI_SET_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "platform/platform.hpp"
#include "rpc/client/client.hpp"
@ -28,9 +30,11 @@
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code set(const int &argc, char *argv[], const std::string &data_directory,
const provider_type &pt, const std::string &unique_id, std::string user,
std::string password) {
[[nodiscard]] inline auto set(int argc, char *argv[],
const std::string &data_directory,
const provider_type &pt,
const std::string &unique_id, std::string user,
std::string password) -> exit_code {
auto ret = exit_code::success;
auto data = utils::cli::parse_option(argc, argv, "-set", 2u);
if (data.empty()) {
@ -48,20 +52,24 @@ static exit_code set(const int &argc, char *argv[], const std::string &data_dire
const auto value = config.set_value_by_name(data[0u], data[1u]);
const auto notFound = value.empty() && not data[1u].empty();
ret = notFound ? exit_code::set_option_not_found : exit_code::success;
std::cout << (notFound ? static_cast<int>(rpc_response_type::config_value_not_found) : 0)
std::cout << (notFound ? static_cast<int>(
rpc_response_type::config_value_not_found)
: 0)
<< std::endl;
std::cout << json({{"value", value}}).dump(2) << std::endl;
} else if (res == lock_result::locked) {
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response =
client({"localhost", password, port, user}).set_config_value_by_name(data[0u], data[1u]);
utils::cli::get_api_authentication_data(user, password, port, pt,
data_directory);
const auto response = client({"localhost", password, port, user})
.set_config_value_by_name(data[0u], data[1u]);
std::cout << static_cast<int>(response.response_type) << std::endl;
std::cout << response.data.dump(2) << std::endl;
ret = response.response_type == rpc_response_type::config_value_not_found
? exit_code::set_option_not_found
: response.response_type == rpc_response_type::success ? exit_code::success
: exit_code::communication_error;
: response.response_type == rpc_response_type::success
? exit_code::success
: exit_code::communication_error;
}
}

View File

@ -1,34 +1,38 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_STATUS_HPP_
#define INCLUDE_CLI_STATUS_HPP_
#include "common.hpp"
#include "platform/platform.hpp"
#include "types/repertory.hpp"
namespace repertory::cli::actions {
static exit_code status(const int &, char *[], const std::string &, const provider_type &pt,
const std::string &unique_id, std::string, std::string) {
[[nodiscard]] inline auto status(int, char *[], const std::string &,
const provider_type &pt,
const std::string &unique_id, std::string,
std::string) -> exit_code {
auto ret = exit_code::success;
lock_data lock(pt, unique_id);
lock.grab_lock(10u);
[[maybe_unused]] auto status = lock.grab_lock(10u);
json mount_state;
if (lock.get_mount_state(mount_state)) {
std::cout << mount_state.dump(2) << std::endl;

View File

@ -1,91 +0,0 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef INCLUDE_CLI_TEST_SKYNET_AUTH_HPP_
#define INCLUDE_CLI_TEST_SKYNET_AUTH_HPP_
#ifdef REPERTORY_ENABLE_SKYNET
#include "common.hpp"
#include "comm/curl/curl_comm.hpp"
#include "app_config.hpp"
#include "events/consumers/console_consumer.hpp"
#include "events/event_system.hpp"
#include "types/repertory.hpp"
#include "utils/cli_utils.hpp"
#include "utils/file_utils.hpp"
#include "utils/path_utils.hpp"
#include "utils/utils.hpp"
namespace repertory::cli::actions {
static exit_code test_skynet_auth(const int &argc, char *argv[], const std::string &,
const provider_type &, const std::string &, std::string,
std::string) {
auto ret = exit_code::success;
auto data = utils::cli::parse_option(argc, argv, "-tsa", 5u);
if (data.empty()) {
data = utils::cli::parse_option(argc, argv, "--test_skynet_auth", 5u);
if (data.empty()) {
ret = exit_code::invalid_syntax;
std::cerr << "Invalid syntax for '-tsa'" << std::endl;
}
}
const auto uuid = utils::create_uuid_string();
const auto config_directory = utils::path::absolute(utils::path::combine("./", {uuid}));
if (ret == exit_code::success) {
utils::file::change_to_process_directory();
{
console_consumer c;
event_system::instance().start();
app_config config(provider_type::skynet, config_directory);
host_config hc{};
hc.auth_url = data[0];
hc.auth_user = data[1];
hc.auth_password = data[2];
hc.agent_string = data[3];
hc.api_password = data[4];
curl_comm comm(config);
std::string session;
CURL *curl_handle = nullptr;
ret = (comm.create_auth_session(curl_handle, config, hc, session))
? exit_code::success
: exit_code::communication_error;
if (ret == exit_code::success) {
curl_easy_cleanup(curl_handle);
comm.release_auth_session(config, hc, session);
}
event_system::instance().stop();
}
if (ret == exit_code::success) {
std::cout << std::endl << "Authentication Succeeded!" << std::endl;
} else {
std::cerr << std::endl << "Authentication Failed!" << std::endl;
}
}
utils::file::delete_directory_recursively(config_directory);
return ret;
}
} // namespace repertory::cli::actions
#endif // REPERTORY_ENABLE_SKYNET
#endif // INCLUDE_CLI_TEST_SKYNET_AUTH_HPP_

View File

@ -1,25 +1,27 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_UNMOUNT_HPP_
#define INCLUDE_CLI_UNMOUNT_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "rpc/client/client.hpp"
#include "types/repertory.hpp"
@ -27,12 +29,15 @@
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code unmount(const int &, char *[], const std::string &data_directory,
const provider_type &pt, const std::string &, std::string user,
std::string password) {
[[nodiscard]] inline auto unmount(int, char *[],
const std::string &data_directory,
const provider_type &pt, const std::string &,
std::string user, std::string password)
-> exit_code {
auto ret = exit_code::success;
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
utils::cli::get_api_authentication_data(user, password, port, pt,
data_directory);
const auto response = client({"localhost", password, port, user}).unmount();
std::cout << static_cast<int>(response.response_type) << std::endl;
if (response.response_type == rpc_response_type::success) {

View File

@ -1,43 +1,48 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_UNPIN_FILE_HPP_
#define INCLUDE_CLI_UNPIN_FILE_HPP_
#include "common.hpp"
#include "app_config.hpp"
#include "rpc/client/client.hpp"
#include "types/repertory.hpp"
#include "types/rpc.hpp"
#include "types/skynet.hpp"
#include "utils/cli_utils.hpp"
namespace repertory::cli::actions {
static exit_code unpin_file(const int &argc, char *argv[], const std::string &data_directory,
const provider_type &pt, const std::string &, std::string user,
std::string password) {
[[nodiscard]] inline auto unpin_file(int argc, char *argv[],
const std::string &data_directory,
const provider_type &pt,
const std::string &, std::string user,
std::string password) -> exit_code {
std::string data;
auto ret = utils::cli::parse_string_option(
argc, argv, repertory::utils::cli::options::unpin_file_option, data);
if (ret == exit_code::success) {
auto port = app_config::default_api_port(pt);
utils::cli::get_api_authentication_data(user, password, port, pt, data_directory);
const auto response = client({"localhost", password, port, user}).unpin_file(data);
utils::cli::get_api_authentication_data(user, password, port, pt,
data_directory);
const auto response =
client({"localhost", password, port, user}).unpin_file(data);
if (response.response_type == rpc_response_type::success) {
std::cout << response.data.dump(2) << std::endl;
} else {

View File

@ -1,30 +1,33 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Copyright <2018-2023> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef INCLUDE_CLI_VERSION_HPP_
#define INCLUDE_CLI_VERSION_HPP_
#include "common.hpp"
namespace repertory::cli::actions {
template <typename drive> static void version(const int &argc, char *argv[]) {
std::cout << "Repertory core version: " << get_repertory_version() << std::endl;
std::cout << "Repertory Git revision: " << get_repertory_git_revision() << std::endl;
template <typename drive> inline void version(int argc, char *argv[]) {
std::cout << "Repertory core version: " << get_repertory_version()
<< std::endl;
std::cout << "Repertory Git revision: " << get_repertory_git_revision()
<< std::endl;
drive::display_version_information(argc, argv);
}
} // namespace repertory::cli::actions