mirror of
https://github.com/usatiuk/backup.git
synced 2025-10-26 09:27:48 +01:00
Compare commits
3 Commits
c888efb366
...
3ef8c796a4
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ef8c796a4 | |||
| f517b0deab | |||
| dba5f06c10 |
@@ -1,5 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.22)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
|
project(backup)
|
||||||
|
|
||||||
if (SANITIZE STREQUAL "YES")
|
if (SANITIZE STREQUAL "YES")
|
||||||
message(WARNING "Enabling sanitizers!")
|
message(WARNING "Enabling sanitizers!")
|
||||||
add_compile_options(-Wall -Wextra -pedantic -Wshadow -Wformat=2 -Wfloat-equal -D_GLIBCXX_DEBUG -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2)
|
add_compile_options(-Wall -Wextra -pedantic -Wshadow -Wformat=2 -Wfloat-equal -D_GLIBCXX_DEBUG -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2)
|
||||||
@@ -12,11 +14,14 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
|||||||
add_link_options(-flto)
|
add_link_options(-flto)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
add_compile_options(-O3)
|
||||||
|
add_link_options(-O3)
|
||||||
|
endif ()
|
||||||
|
|
||||||
add_compile_options(-rdynamic)
|
add_compile_options(-rdynamic)
|
||||||
add_link_options(-rdynamic)
|
add_link_options(-rdynamic)
|
||||||
|
|
||||||
project(backup)
|
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|||||||
@@ -13,4 +13,6 @@ add_subdirectory(utils)
|
|||||||
add_subdirectory(fuse)
|
add_subdirectory(fuse)
|
||||||
|
|
||||||
add_executable(backup main.cpp)
|
add_executable(backup main.cpp)
|
||||||
target_link_libraries(backup PRIVATE change_detectors chunkers commands crypto filters repo utils)
|
target_link_libraries(backup PRIVATE change_detectors chunkers commands crypto filters repo utils)
|
||||||
|
|
||||||
|
install(TARGETS backup DESTINATION bin)
|
||||||
@@ -95,7 +95,6 @@ void CommandRun::run(Context ctx) {
|
|||||||
File repoFile = Serialize::deserialize<File>(ctx.repo->getObject(Object::ObjectType::File, relPath));
|
File repoFile = Serialize::deserialize<File>(ctx.repo->getObject(Object::ObjectType::File, relPath));
|
||||||
if (!changeDetector.check({repoFile, ctx.repo}, {p, from})) {
|
if (!changeDetector.check({repoFile, ctx.repo}, {p, from})) {
|
||||||
addFile(repoFile.id);
|
addFile(repoFile.id);
|
||||||
ctx.repo->addToCache(repoFile);
|
|
||||||
progress.print("Skipped: " + relPath, 1);
|
progress.print("Skipped: " + relPath, 1);
|
||||||
runnerStats.filesSkipped++;
|
runnerStats.filesSkipped++;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -43,9 +43,6 @@ public:
|
|||||||
Object::idType getObjectId(Object::ObjectType type, const std::string &key) const override;
|
Object::idType getObjectId(Object::ObjectType type, const std::string &key) const override;
|
||||||
std::vector<std::pair<std::string, Object::idType>> getObjects(Object::ObjectType type) const override;
|
std::vector<std::pair<std::string, Object::idType>> getObjects(Object::ObjectType type) const override;
|
||||||
|
|
||||||
bool clearCache(Object::ObjectType type) override;
|
|
||||||
bool addToCache(const Object &obj) override;
|
|
||||||
|
|
||||||
bool exists(Object::ObjectType type, const std::string &key) const override;
|
bool exists(Object::ObjectType type, const std::string &key) const override;
|
||||||
Object::idType getId() override;
|
Object::idType getId() override;
|
||||||
|
|
||||||
|
|||||||
@@ -85,18 +85,7 @@ public:
|
|||||||
/// \return True if exists, False otherwise
|
/// \return True if exists, False otherwise
|
||||||
/// \throws Exception on any error
|
/// \throws Exception on any error
|
||||||
virtual bool exists(Object::ObjectType type, const std::string &key) const = 0;
|
virtual bool exists(Object::ObjectType type, const std::string &key) const = 0;
|
||||||
|
|
||||||
/// Erases all the cache entries of object type \p type
|
|
||||||
/// \param type Type of the objects
|
|
||||||
/// \return True
|
|
||||||
virtual bool clearCache(Object::ObjectType type) = 0;
|
|
||||||
|
|
||||||
/// Adds the object to the cache, but doesn't change it on disk otherwise
|
|
||||||
/// \param obj Constant reference to the object
|
|
||||||
/// \return True
|
|
||||||
/// \throws Exception on any error, or if the object doesn't exist
|
|
||||||
virtual bool addToCache(const Object &obj) = 0;
|
|
||||||
|
|
||||||
/// Returns the next available object id
|
/// Returns the next available object id
|
||||||
virtual Object::idType getId() = 0;
|
virtual Object::idType getId() = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -225,22 +225,3 @@ void FileRepository::OffsetEntry::serialize(std::vector<char> &out) const {
|
|||||||
|
|
||||||
FileRepository::OffsetEntry::OffsetEntry(unsigned long long int fileId, unsigned long long int offset, unsigned long long int length)
|
FileRepository::OffsetEntry::OffsetEntry(unsigned long long int fileId, unsigned long long int offset, unsigned long long int length)
|
||||||
: fileId(fileId), offset(offset), length(length) {}
|
: fileId(fileId), offset(offset), length(length) {}
|
||||||
|
|
||||||
bool FileRepository::clearCache(Object::ObjectType type) {
|
|
||||||
keyIndex[type] = {};
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FileRepository::addToCache(const Object &obj) {
|
|
||||||
{
|
|
||||||
std::unique_lock lock(repoLock);
|
|
||||||
if (offsetIndex.count(obj.id) == 0)
|
|
||||||
throw Exception("Object with id " + std::to_string(obj.id) + " doesn't exist!");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
std::lock_guard lock(repoLock);
|
|
||||||
keyIndex[obj.type][obj.getKey()] = obj.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ FetchContent_Declare(
|
|||||||
)
|
)
|
||||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||||
|
set(INSTALL_GTEST OFF)
|
||||||
FetchContent_MakeAvailable(googletest)
|
FetchContent_MakeAvailable(googletest)
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ AIDS=()
|
|||||||
OUT=$($CMD list --repo "$TESTDATADIR"/testdir/to1 --password asdff)
|
OUT=$($CMD list --repo "$TESTDATADIR"/testdir/to1 --password asdff)
|
||||||
echo "$OUT"
|
echo "$OUT"
|
||||||
|
|
||||||
mkdir "$TESTDATADIR"/testmount
|
mkdir -p "$TESTDATADIR"/testmount
|
||||||
$CMD mount --repo "$TESTDATADIR"/testdir/to1 --password asdff --to "$TESTDATADIR"/testmount &
|
$CMD mount --repo "$TESTDATADIR"/testdir/to1 --password asdff --to "$TESTDATADIR"/testmount &
|
||||||
|
|
||||||
while IFS= read -r l; do
|
while IFS= read -r l; do
|
||||||
|
|||||||
Reference in New Issue
Block a user