2022-10-21 19:39:55 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
2022-10-22 00:43:34 +02:00
|
|
|
#include <dirent.h>
|
2022-10-21 19:39:55 +02:00
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "file.h"
|
2022-10-23 00:48:15 +02:00
|
|
|
#include "fileindexer.h"
|
2022-10-21 19:39:55 +02:00
|
|
|
#include "files.h"
|
|
|
|
#include "searchfolder.h"
|
|
|
|
|
|
|
|
class Dedup {
|
|
|
|
public:
|
|
|
|
Dedup();
|
|
|
|
~Dedup();
|
|
|
|
|
|
|
|
void addSearchFolder(const std::string& path, bool recurse = true);
|
|
|
|
|
|
|
|
void start();
|
|
|
|
|
|
|
|
private:
|
2022-10-23 00:48:15 +02:00
|
|
|
void removeUninterestingFiles(std::multimap<uint64_t, std::shared_ptr<File>>& files);
|
2022-10-22 00:43:34 +02:00
|
|
|
|
2022-10-23 00:48:15 +02:00
|
|
|
std::map<uint64_t, Files> hash(std::multimap<uint64_t, std::shared_ptr<File>>& files, uint64_t bytestohash);
|
2022-10-21 19:39:55 +02:00
|
|
|
|
2022-10-23 00:48:15 +02:00
|
|
|
void resolveDuplicates(std::map<uint64_t, Files>& hashed);
|
|
|
|
bool relinkFile(const std::string& linkbase, const std::string& replacedfile);
|
2022-10-22 00:43:34 +02:00
|
|
|
|
2022-10-23 15:43:26 +02:00
|
|
|
static const uint_fast8_t HASHTHREADCOUNT;
|
|
|
|
|
2022-10-21 19:39:55 +02:00
|
|
|
std::vector<SearchFolder> folders;
|
2022-10-23 00:48:15 +02:00
|
|
|
FileIndexer indexer;
|
2022-10-21 19:39:55 +02:00
|
|
|
|
|
|
|
bool hardlink = true;
|
2022-10-22 00:43:34 +02:00
|
|
|
bool ignoredotfiles = false;
|
2022-10-23 00:48:15 +02:00
|
|
|
bool dryrun = true;
|
2022-11-08 21:51:29 +01:00
|
|
|
bool deleteDuplicates = true;
|
|
|
|
bool ignoreInodeID = true;
|
2022-10-23 00:48:15 +02:00
|
|
|
uint64_t deduplicatedBytes = 0; // amount of bytes deduplicated
|
|
|
|
uint64_t deduplicatedFiles = 0;
|
2022-10-21 19:39:55 +02:00
|
|
|
};
|