forked from pool/fdupes
ebd601a9d7
- update to 1.5.0-PR2 * new "--summarize" option * new "--recurse:" selective recursion option * new "--noprompt" option for totally automated deletion of duplicate files. * sorts duplicates (old to new) for consistent order when listing or deleteing duplicate files. * tests for early matching of files, which should help speed up the matching process when large files are involved. * warns whenever a file cannot be deleted. * bugfixes (proper file closing, zero-length files, ...) - add -p/--permissions switch so files with different permissions or uid/gid are not considered as duplicates (bnc#784670) * this mode is a default one for fdupes macro - refresh all patches - drop the fdupes-sort-output.diff - use the upstream mtime sorting - add the debian patches - see spec file for details OBS-URL: https://build.opensuse.org/request/show/138346 OBS-URL: https://build.opensuse.org/package/show/utilities/fdupes?expand=0&rev=6
74 lines
2.3 KiB
Diff
74 lines
2.3 KiB
Diff
From 1e8e84ee52397881558e083bcae4d243d319e811 Mon Sep 17 00:00:00 2001
|
|
From: Sandro Tosi <matrixhasu@gmail.com>
|
|
Date: Fri, 12 Oct 2012 14:54:42 +0200
|
|
Subject: [PATCH 01/10] restore pristine code
|
|
|
|
speedup the file compare by reading larger buffers, comparing the
|
|
results of fread and so
|
|
---
|
|
fdupes.c | 25 +++++++++++++++----------
|
|
1 file changed, 15 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/fdupes.c b/fdupes.c
|
|
index 4b870b2..f16e4e0 100644
|
|
--- a/fdupes.c
|
|
+++ b/fdupes.c
|
|
@@ -492,7 +492,10 @@ file_t **checkmatch(filetree_t **root, filetree_t *checktree, file_t *file)
|
|
else {
|
|
if (checktree->file->crcpartial == NULL) {
|
|
crcsignature = getcrcpartialsignature(checktree->file->d_name);
|
|
- if (crcsignature == NULL) return NULL;
|
|
+ if (crcsignature == NULL) {
|
|
+ errormsg ("cannot read file %s\n", checktree->file->d_name);
|
|
+ return NULL;
|
|
+ }
|
|
|
|
checktree->file->crcpartial = (char*) malloc(strlen(crcsignature)+1);
|
|
if (checktree->file->crcpartial == NULL) {
|
|
@@ -504,7 +507,10 @@ file_t **checkmatch(filetree_t **root, filetree_t *checktree, file_t *file)
|
|
|
|
if (file->crcpartial == NULL) {
|
|
crcsignature = getcrcpartialsignature(file->d_name);
|
|
- if (crcsignature == NULL) return NULL;
|
|
+ if (crcsignature == NULL) {
|
|
+ errormsg ("cannot read file %s\n", file->d_name);
|
|
+ return NULL;
|
|
+ }
|
|
|
|
file->crcpartial = (char*) malloc(strlen(crcsignature)+1);
|
|
if (file->crcpartial == NULL) {
|
|
@@ -577,8 +583,8 @@ file_t **checkmatch(filetree_t **root, filetree_t *checktree, file_t *file)
|
|
|
|
int confirmmatch(FILE *file1, FILE *file2)
|
|
{
|
|
- unsigned char c1 = 0;
|
|
- unsigned char c2 = 0;
|
|
+ unsigned char c1[CHUNK_SIZE];
|
|
+ unsigned char c2[CHUNK_SIZE];
|
|
size_t r1;
|
|
size_t r2;
|
|
|
|
@@ -586,14 +592,13 @@ int confirmmatch(FILE *file1, FILE *file2)
|
|
fseek(file2, 0, SEEK_SET);
|
|
|
|
do {
|
|
- r1 = fread(&c1, sizeof(c1), 1, file1);
|
|
- r2 = fread(&c2, sizeof(c2), 1, file2);
|
|
+ r1 = fread(c1, 1, sizeof(c1), file1);
|
|
+ r2 = fread(c2, 1, sizeof(c2), file2);
|
|
|
|
- if (c1 != c2) return 0; /* file contents are different */
|
|
- } while (r1 && r2);
|
|
+ if (r1 != r2) return 0; /* file lengths are different */
|
|
+ if (memcmp (c1, c2, r1)) return 0; /* file contents are different */
|
|
+ } while (r2);
|
|
|
|
- if (r1 != r2) return 0; /* file lengths are different */
|
|
-
|
|
return 1;
|
|
}
|
|
|
|
--
|
|
1.7.11.5
|
|
|