Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow for '-checksum none' to disable checksum filtering. #118 #119

Open
wants to merge 4 commits into
base: devel
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions .github/workflows/gcc11.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: gcc 11

on: [push, pull_request]


jobs:
build:
name: Compiles with gcc 11
runs-on: ubuntu-20.04

steps:
- name: checkout
uses: actions/checkout@v2
- name: install packages
run: sudo apt install build-essential nettle-dev time gcc-11 g++-11
- name: bootstrap
run: ./bootstrap.sh
- name: configure
run: ./configure CXX=g++-11
- name: build
run: make
- name: check
run: make check
- name: store the logs as an artifact
if: ${{ always() }}
uses: actions/[email protected]
with:
path: '**/*.log'

1 change: 0 additions & 1 deletion lgtm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ extraction:
- nettle-dev
configure:
command:
- grep -v AX_CXX_COMPILE_STDCXX <configure.ac >tmp && mv tmp configure.ac
- ./bootstrap.sh
- ./configure
38 changes: 23 additions & 15 deletions rdfind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// std
#include <algorithm>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

Expand Down Expand Up @@ -60,7 +61,7 @@ usage()
<< " -followsymlinks true |(false) follow symlinks\n"
<< " -removeidentinode (true)| false ignore files with nonunique "
"device and inode\n"
<< " -checksum md5 |(sha1)| sha256\n"
<< " -checksum md5 |(sha1)| sha256 | none\n"
<< " checksum type\n"
<< " -deterministic (true)| false makes results independent of order\n"
<< " from listing the filesystem\n"
Expand Down Expand Up @@ -102,6 +103,7 @@ struct Options
bool followsymlinks = false; // follow symlinks
bool dryrun = false; // only dryrun, don't destroy anything
bool remove_identical_inode = true; // remove files with identical inodes
bool checksum = true; // use some checksum
bool usemd5 = false; // use md5 checksum to check for similarity
bool usesha1 = false; // use sha1 checksum to check for similarity
bool usesha256 = false; // use sha256 checksum to check for similarity
Expand Down Expand Up @@ -173,8 +175,10 @@ parseOptions(Parser& parser)
o.usesha1 = true;
} else if (parser.parsed_string_is("sha256")) {
o.usesha256 = true;
} else if (parser.parsed_string_is("none")) {
o.checksum = false;
} else {
std::cerr << "expected md5/sha1/sha256, not \""
std::cerr << "expected md5/sha1/sha256/none, not \""
<< parser.get_parsed_string() << "\"\n";
std::exit(EXIT_FAILURE);
}
Expand Down Expand Up @@ -236,8 +240,10 @@ parseOptions(Parser& parser)
// done with parsing of options. remaining arguments are files and dirs.

// decide what checksum to use - if no checksum is set, force sha1!
if (!o.usemd5 && !o.usesha1 && !o.usesha256) {
o.usesha1 = true;
if (o.checksum) {
if (!o.usemd5 && !o.usesha1 && !o.usesha256) {
o.usesha1 = true;
}
}
return o;
}
Expand Down Expand Up @@ -355,17 +361,19 @@ main(int narg, const char* argv[])
{ Fileinfo::readtobuffermode::READ_FIRST_BYTES, "first bytes" },
{ Fileinfo::readtobuffermode::READ_LAST_BYTES, "last bytes" },
};
if (o.usemd5) {
modes.emplace_back(Fileinfo::readtobuffermode::CREATE_MD5_CHECKSUM,
"md5 checksum");
}
if (o.usesha1) {
modes.emplace_back(Fileinfo::readtobuffermode::CREATE_SHA1_CHECKSUM,
"sha1 checksum");
}
if (o.usesha256) {
modes.emplace_back(Fileinfo::readtobuffermode::CREATE_SHA256_CHECKSUM,
"sha256 checksum");
if (o.checksum) {
if (o.usemd5) {
modes.emplace_back(Fileinfo::readtobuffermode::CREATE_MD5_CHECKSUM,
"md5 checksum");
}
if (o.usesha1) {
modes.emplace_back(Fileinfo::readtobuffermode::CREATE_SHA1_CHECKSUM,
"sha1 checksum");
}
if (o.usesha256) {
modes.emplace_back(Fileinfo::readtobuffermode::CREATE_SHA256_CHECKSUM,
"sha256 checksum");
}
}

for (auto it = modes.begin() + 1; it != modes.end(); ++it) {
Expand Down