summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-10-25 10:41:40 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-10-25 10:41:40 +0900
commit12aed66e35bdc6148fcaf31219b9fef54dcfd5c9 (patch)
treeb0b9453508fa59f75be98e00c437b246187d1bbf
parentff382fde104ffe6b03a4913cf48bfe8617276346 (diff)
downloadfdupes-12aed66e35bdc6148fcaf31219b9fef54dcfd5c9.tar.gz
fdupes-12aed66e35bdc6148fcaf31219b9fef54dcfd5c9.tar.bz2
fdupes-12aed66e35bdc6148fcaf31219b9fef54dcfd5c9.zip
Imported Upstream version 2.1.2upstream/2.1.2
-rw-r--r--CHANGES5
-rw-r--r--configure.ac10
-rw-r--r--fdupes.112
-rw-r--r--fdupes.c145
4 files changed, 97 insertions, 75 deletions
diff --git a/CHANGES b/CHANGES
index 1959c8e..e6ec5dc 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,11 @@ who contributed the patch or idea appears first, followed by
those who've otherwise worked on that item. For a list of
contributors names and identifiers please see the CONTRIBUTORS file.
+Changes from 2.1.1 to 2.1.2:
+
+ - Do not enter ncurses mode when --immediate option given.
+ - Fix logging/memory corruption bug when using --log with --immediate.
+
Changes from 2.1.0 to 2.1.1:
- Break mtime ties using ctime when sorting by time.
diff --git a/configure.ac b/configure.ac
index 22b4503..98cd8a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([fdupes], [2.1.1])
+AC_INIT([fdupes], [2.1.2])
AM_INIT_AUTOMAKE([foreign subdir-objects])
@@ -6,12 +6,18 @@ AC_CONFIG_HEADERS([config.h])
AC_ARG_PROGRAM
+PKG_PROG_PKG_CONFIG
+
AC_ARG_WITH([ncurses], AS_HELP_STRING([--without-ncurses], [Do not use ncurses interface]))
AC_CHECK_HEADERS([getopt.h ncursesw/curses.h])
AS_IF([test x"$with_ncurses" != x"no"],
- [AC_SEARCH_LIBS([wget_wch], [ncursesw ncurses curses], [], [AC_ERROR([ncurses library not found (or lacks wide character support)])])]
+ [PKG_CHECK_MODULES([NCURSES], [ncursesw],
+ [LIBS="$LIBS $NCURSES_LIBS"],
+ [AC_SEARCH_LIBS([wget_wch], [ncursesw ncurses curses], [], [AC_ERROR([ncurses library not found (or lacks wide character support)])])]
+ [AC_SEARCH_LIBS([keypad], [ncursesw tinfow ncurses tinfo curses], [], [AC_ERROR([ncurses library not found (lacks keypad support)])])]
+ )]
[AC_DEFINE([_XOPEN_SOURCE], [], [enable certain functions in wchar.h])]
[AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [], [enable certain functions in curses.h])]
[AC_DEFINE([_ISOC99_SOURCE], [], [enable strtoll])]
diff --git a/fdupes.1 b/fdupes.1
index 70c3c3e..56cd6fd 100644
--- a/fdupes.1
+++ b/fdupes.1
@@ -98,9 +98,6 @@ display fdupes version
.TP
.B -h --help
displays help
-.SH "SEE ALSO"
-.\" Always quote multiple words for .SH
-.BR md5sum (1)
.SH NOTES
Unless
.B -1
@@ -126,15 +123,6 @@ will follow subdirectories under b, but not those under a.
will follow subdirectories under both a and b.
.SH CAVEATS
-If fdupes returns with an error message such as
-.B fdupes: error invoking md5sum
-it means the program has been compiled to use an external
-program to calculate MD5 signatures (otherwise, fdupes uses
-internal routines for this purpose), and an error has occurred
-while attempting to execute it. If this is the case, the
-specified program should be properly installed prior
-to running fdupes.
-
When using
.B \-d
or
diff --git a/fdupes.c b/fdupes.c
index 61f31f7..46caa80 100644
--- a/fdupes.c
+++ b/fdupes.c
@@ -285,6 +285,7 @@ int grokdir(char *dir, file_t **filelistp, struct stat *logfile_status)
if (name[0] == '.' && strcmp(name, ".") && strcmp(name, "..") ) {
free(newfile->d_name);
free(newfile);
+ free(fullname);
continue;
}
free(fullname);
@@ -302,6 +303,7 @@ int grokdir(char *dir, file_t **filelistp, struct stat *logfile_status)
continue;
}
+ /* ignore logfile */
if (info.st_dev == logfile_status->st_dev && info.st_ino == logfile_status->st_ino)
{
free(newfile->d_name);
@@ -1152,6 +1154,9 @@ void deletesuccessor(file_t **existing, file_t *duplicate,
if (!ISFLAG(flags, F_HIDEPROGRESS)) fprintf(stderr, "\r%40s\r", " ");
+ if (loginfo)
+ log_begin_set(loginfo);
+
printf(" [+] %s\n", to_keep->d_name);
if (loginfo)
@@ -1170,6 +1175,9 @@ void deletesuccessor(file_t **existing, file_t *duplicate,
log_file_remaining(loginfo, to_delete->d_name);
}
+ if (loginfo)
+ log_end_set(loginfo);
+
printf("\n");
}
@@ -1177,49 +1185,52 @@ void help_text()
{
printf("Usage: fdupes [options] DIRECTORY...\n\n");
- printf(" -r --recurse \tfor every directory given follow subdirectories\n");
- printf(" \tencountered within\n");
- printf(" -R --recurse: \tfor each directory given after this option follow\n");
- printf(" \tsubdirectories encountered within (note the ':' at\n");
- printf(" \tthe end of the option, manpage for more details)\n");
- printf(" -s --symlinks \tfollow symlinks\n");
- printf(" -H --hardlinks \tnormally, when two or more files point to the same\n");
- printf(" \tdisk area they are treated as non-duplicates; this\n");
- printf(" \toption will change this behavior\n");
- printf(" -G --minsize=SIZE\tconsider only files greater than or equal to SIZE\n");
- printf(" -L --maxsize=SIZE\tconsider only files less than or equal to SIZE\n");
- printf(" -n --noempty \texclude zero-length files from consideration\n");
- printf(" -A --nohidden \texclude hidden files from consideration\n");
- printf(" -f --omitfirst \tomit the first file in each set of matches\n");
- printf(" -1 --sameline \tlist each set of matches on a single line\n");
- printf(" -S --size \tshow size of duplicate files\n");
- printf(" -t --time \tshow modification time of duplicate files\n");
- printf(" -m --summarize \tsummarize dupe information\n");
- printf(" -q --quiet \thide progress indicator\n");
- printf(" -d --delete \tprompt user for files to preserve and delete all\n");
- printf(" \tothers; important: under particular circumstances,\n");
- printf(" \tdata may be lost when using this option together\n");
- printf(" \twith -s or --symlinks, or when specifying a\n");
- printf(" \tparticular directory more than once; refer to the\n");
- printf(" \tfdupes documentation for additional information\n");
+ /* 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0
+ -------"---------|---------|---------|---------|---------|---------|---------|---------|"
+ */
+ printf(" -r --recurse for every directory given follow subdirectories\n");
+ printf(" encountered within\n");
+ printf(" -R --recurse: for each directory given after this option follow\n");
+ printf(" subdirectories encountered within (note the ':' at the\n");
+ printf(" end of the option, manpage for more details)\n");
+ printf(" -s --symlinks follow symlinks\n");
+ printf(" -H --hardlinks normally, when two or more files point to the same\n");
+ printf(" disk area they are treated as non-duplicates; this\n");
+ printf(" option will change this behavior\n");
+ printf(" -G --minsize=SIZE consider only files greater than or equal to SIZE bytes\n");
+ printf(" -L --maxsize=SIZE consider only files less than or equal to SIZE bytes\n");
+ printf(" -n --noempty exclude zero-length files from consideration\n");
+ printf(" -A --nohidden exclude hidden files from consideration\n");
+ printf(" -f --omitfirst omit the first file in each set of matches\n");
+ printf(" -1 --sameline list each set of matches on a single line\n");
+ printf(" -S --size show size of duplicate files\n");
+ printf(" -t --time show modification time of duplicate files\n");
+ printf(" -m --summarize summarize dupe information\n");
+ printf(" -q --quiet hide progress indicator\n");
+ printf(" -d --delete prompt user for files to preserve and delete all\n");
+ printf(" others; important: under particular circumstances,\n");
+ printf(" data may be lost when using this option together\n");
+ printf(" with -s or --symlinks, or when specifying a\n");
+ printf(" particular directory more than once; refer to the\n");
+ printf(" fdupes documentation for additional information\n");
#ifndef NO_NCURSES
- printf(" -P --plain \twith --delete, use line-based prompt (as with older\n");
- printf(" \tversions of fdupes) instead of screen-mode interface\n");
+ printf(" -P --plain with --delete, use line-based prompt (as with older\n");
+ printf(" versions of fdupes) instead of screen-mode interface\n");
#endif
- printf(" -N --noprompt \ttogether with --delete, preserve the first file in\n");
- printf(" \teach set of duplicates and delete the rest without\n");
- printf(" \tprompting the user\n");
- printf(" -I --immediate \tdelete duplicates as they are encountered, without\n");
- printf(" \tgrouping into sets; implies --noprompt\n");
- printf(" -p --permissions \tdon't consider files with different owner/group or\n");
- printf(" \tpermission bits as duplicates\n");
- printf(" -o --order=BY \tselect sort order for output and deleting; by file\n");
- printf(" \tmodification time (BY='time'; default), status\n");
- printf(" \tchange time (BY='ctime'), or filename (BY='name')\n");
- printf(" -i --reverse \treverse order while sorting\n");
- printf(" -l --log=LOGFILE \tlog file deletion choices to LOGFILE\n");
- printf(" -v --version \tdisplay fdupes version\n");
- printf(" -h --help \tdisplay this help message\n\n");
+ printf(" -N --noprompt together with --delete, preserve the first file in\n");
+ printf(" each set of duplicates and delete the rest without\n");
+ printf(" prompting the user\n");
+ printf(" -I --immediate delete duplicates as they are encountered, without\n");
+ printf(" grouping into sets; implies --noprompt\n");
+ printf(" -p --permissions don't consider files with different owner/group or\n");
+ printf(" permission bits as duplicates\n");
+ printf(" -o --order=BY select sort order for output and deleting; by file\n");
+ printf(" modification time (BY='time'; default), status\n");
+ printf(" change time (BY='ctime'), or filename (BY='name')\n");
+ printf(" -i --reverse reverse order while sorting\n");
+ printf(" -l --log=LOGFILE log file deletion choices to LOGFILE\n");
+ printf(" -v --version display fdupes version\n");
+ printf(" -h --help display this help message\n\n");
#ifndef HAVE_GETOPT_H
printf("Note: Long options are not supported in this fdupes build.\n\n");
#endif
@@ -1239,7 +1250,7 @@ int main(int argc, char **argv) {
char **oldargv;
int firstrecurse;
char *logfile = 0;
- struct log_info *loginfo;
+ struct log_info *loginfo = NULL;
int log_error;
struct stat logfile_status;
char *endptr;
@@ -1380,24 +1391,7 @@ int main(int argc, char **argv) {
SETFLAG(flags, F_REVERSE);
break;
case 'l':
- loginfo = log_open(logfile=optarg, &log_error);
- if (loginfo == 0)
- {
- if (log_error == LOG_ERROR_NOT_A_LOG_FILE)
- errormsg("%s: doesn't look like an fdupes log file\n", logfile);
- else
- errormsg("%s: could not open log file\n", logfile);
-
- exit(1);
- }
- log_close(loginfo);
-
- if (stat(logfile, &logfile_status) != 0)
- {
- errormsg("could not read log file status\n");
- exit(1);
- }
-
+ logfile = optarg;
break;
default:
fprintf(stderr, "Try `fdupes --help' for more information.\n");
@@ -1420,6 +1414,29 @@ int main(int argc, char **argv) {
exit(1);
}
+ if (!ISFLAG(flags, F_DELETEFILES))
+ logfile = 0;
+
+ if (logfile != 0)
+ {
+ loginfo = log_open(logfile, &log_error);
+ if (loginfo == 0)
+ {
+ if (log_error == LOG_ERROR_NOT_A_LOG_FILE)
+ errormsg("%s: doesn't look like an fdupes log file\n", logfile);
+ else
+ errormsg("%s: could not open log file\n", logfile);
+
+ exit(1);
+ }
+
+ if (stat(logfile, &logfile_status) != 0)
+ {
+ errormsg("could not read log file status\n");
+ exit(1);
+ }
+ }
+
if (ISFLAG(flags, F_RECURSEAFTER)) {
firstrecurse = nonoptafter("--recurse:", argc, oldargv, argv, optind);
@@ -1500,9 +1517,15 @@ int main(int argc, char **argv) {
if (!ISFLAG(flags, F_HIDEPROGRESS)) fprintf(stderr, "\r%40s\r", " ");
+ if (loginfo != 0)
+ {
+ log_close(loginfo);
+ loginfo = 0;
+ }
+
if (ISFLAG(flags, F_DELETEFILES))
{
- if (ISFLAG(flags, F_NOPROMPT))
+ if (ISFLAG(flags, F_NOPROMPT) || ISFLAG(flags, F_IMMEDIATE))
{
deletefiles(files, 0, 0, logfile);
}