Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ find_package(boost_lexical_cast CONFIG REQUIRED)
find_package(boost_uuid CONFIG REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(glog REQUIRED)
find_package(fmt CONFIG REQUIRED)

# Organization info
set(PROJECT_ORG_NAME "Cadons")
Expand Down
2 changes: 1 addition & 1 deletion lib/tusclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ target_include_directories(tusclient PUBLIC
$<INSTALL_INTERFACE:include/tusclient>)

# Link libraries
target_link_libraries(tusclient PUBLIC CURL::libcurl Boost::uuid Boost::lexical_cast nlohmann_json::nlohmann_json glog::glog)
target_link_libraries(tusclient PUBLIC CURL::libcurl Boost::uuid Boost::lexical_cast nlohmann_json::nlohmann_json glog::glog fmt::fmt)
if(BUILD_SHARED_LIBS)
target_compile_definitions(tusclient PRIVATE TUSCLIENT_EXPORTS)
target_compile_definitions(tusclient PRIVATE TUSCLIENT_SHARED)
Expand Down
34 changes: 0 additions & 34 deletions lib/tusclient/LICENSE

This file was deleted.

10 changes: 5 additions & 5 deletions lib/tusclient/src/tusclient/TusClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <fstream>
#include <iostream>
#include <thread>
#include <format>
#include <fmt/core.h>

#include "TusClient.h"
#include "cache/CacheRepository.h"
Expand Down Expand Up @@ -154,7 +154,7 @@ bool TusClient::upload() {
m_tusLocation.replace(0, lastSlashPosition + 1, "");
} else {
// Handle the case where '/' is not found in m_tusLocation
std::cerr << std::format("Invalid upload URL: The URL is empty or invalid.\n"
std::cerr << fmt::format("Invalid upload URL: The URL is empty or invalid.\n"
"Please ensure the URL is a complete TUS server endpoint (e.g., 'http://localhost:8080/files/')\n"
"Current URL: '{}'\n", m_url) << std::endl;
}
Expand Down Expand Up @@ -234,7 +234,7 @@ void TusClient::handleUploadConflict(const string &header) {
m_logger->warning("Conflict detected, retrying the upload");
getUploadInfo();
} else {
m_logger->error(std::format("Error: Too many conflicts {}", m_uploadedChunks));
m_logger->error(fmt::format("Error: Too many conflicts {}", m_uploadedChunks));
m_logger->error(header);
m_status.store(TusStatus::FAILED);
throw TUS::Exceptions::TUSException("Error: Too many conflicts");
Expand All @@ -243,7 +243,7 @@ void TusClient::handleUploadConflict(const string &header) {
}

void TusClient::handleUploadError(const string &header) {
m_logger->error(std::format("Error: Unable to upload chunk {}", m_uploadedChunks));
m_logger->error(fmt::format("Error: Unable to upload chunk {}", m_uploadedChunks));
m_logger->error(header);
m_status.store(TusStatus::FAILED);
throw TUS::Exceptions::TUSException("Error: Unable to upload chunk");
Expand Down Expand Up @@ -284,7 +284,7 @@ void TusClient::uploadChunk(int chunkNumber) {
throw TUS::Exceptions::TUSException("Error: Unable to upload chunk");
}
};
m_logger->debug(std::format("Uploading chunk {}", chunkNumber));
m_logger->debug(fmt::format("Uploading chunk {}", chunkNumber));
m_httpClient->patch(Http::Request(
m_url + m_tusLocation,
std::string(reinterpret_cast<char *>(chunk.getData().data()),
Expand Down
4 changes: 2 additions & 2 deletions lib/tusclient/src/tusclient/chunk/FileChunker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "chunk/TUSChunk.h"
#include "chunk/utility/ChunkUtility.h"
#include "verifiers/Md5Verifier.h"
#include <format>
#include <fmt/core.h>

using TUS::Chunk::FileChunker;
using TUS::Chunk::TUSChunk;
Expand Down Expand Up @@ -67,7 +67,7 @@ std::filesystem::path FileChunker::getTemporaryDir() const {
}

std::string FileChunker::getChunkFilename(int chunkNumber) const {
return std::format("{}{}{}{}", m_uuid, CHUNK_FILE_NAME_PREFIX, chunkNumber, CHUNK_FILE_EXTENSION);
return fmt::format("{}{}{}{}", m_uuid, CHUNK_FILE_NAME_PREFIX, chunkNumber, CHUNK_FILE_EXTENSION);
}

std::filesystem::path FileChunker::getChunkFilePath(int chunkNumber) const {
Expand Down
4 changes: 2 additions & 2 deletions lib/tusclient/src/tusclient/verifiers/Md5Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <boost/uuid/detail/md5.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <iomanip>

#include <fmt/core.h>
#include "verifiers/Md5Verifier.h"


Expand All @@ -28,7 +28,7 @@ string Md5Verifier::hash(const std::vector<uint8_t> &buffer) const {

std::string result;
for (const unsigned char i : digest) {
result += std::format("{:02x}", static_cast<int>(i));
result += fmt::format("{:02x}", static_cast<int>(i));
}
return result;
}
Expand Down
10 changes: 5 additions & 5 deletions lib/tusclient/test/TusClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <filesystem>
#include <thread>
#include <chrono>
#include <format>
#include <fmt/core.h>
#include "TusClient.h"

/**
Expand All @@ -36,7 +36,7 @@ namespace TUS::Test {
std::filesystem::remove("test.zip");

for (int i = 0; i < MAX_CLEANUP_FILES; ++i) {
std::filesystem::remove(std::format("{}.dat", i));
std::filesystem::remove(fmt::format("{}.dat", i));
}
}
private:
Expand Down Expand Up @@ -65,7 +65,7 @@ namespace TUS::Test {
return static_cast<char>(dis(gen));
});

std::ofstream datFile(std::format("{}.dat", i), std::ios::binary);
std::ofstream datFile(fmt::format("{}.dat", i), std::ios::binary);
datFile.write(data.data(), data.size());
});
}
Expand All @@ -76,12 +76,12 @@ namespace TUS::Test {
zipArchive.open(libzippp::ZipArchive::New);

for (int i = 0; i < size; ++i) {
zipArchive.addFile(std::to_string(i), std::format("{}.dat", i));
zipArchive.addFile(std::to_string(i), fmt::format("{}.dat", i));
}
zipArchive.close();

for (int i = 0; i < size; ++i) {
std::filesystem::remove(std::format("{}.dat", i));
std::filesystem::remove(fmt::format("{}.dat", i));
}

return "test.zip";
Expand Down
2 changes: 1 addition & 1 deletion project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "tusclient",
"name": "cadons-ctus",
"organization": "Cadons",
"package_manager": "vcpkg",
"version": "1.0.0",
Expand Down
16 changes: 4 additions & 12 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "tusclient",
"name": "cadons-ctus",
"license": "MIT",
"version": "1.0.0",
"description": "Library implementing the tus protocol for resumable uploads",
Expand Down Expand Up @@ -34,16 +34,8 @@
},
{
"name": "glog"
},
"vcpkg-cmake",
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"shared": {
"description": "Build shared libraries"
},{
"name": "fmt"
}
}
]
}
Loading