mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-16 18:48:41 -09:00
symlinks: Only call stat_to_dir() once, impove manual
stat_to_dir() assumes that buf_dir is clean; calling it twice breaks that asumption.
This commit is contained in:
parent
74efdfaf97
commit
882a32613d
2 changed files with 12 additions and 12 deletions
|
|
@ -174,8 +174,10 @@ See http://www.brynosaurus.com/cachedir/
|
||||||
|
|
||||||
=item -L, --follow-symlinks
|
=item -L, --follow-symlinks
|
||||||
|
|
||||||
Follow symlinks (except to directories) 00and count the size of the file
|
Follow symlinks and count the size of the file they point to. As of ncdu 1.14,
|
||||||
they point to. Symlink loops and directories will be ignored.
|
this option will not follow symlinks to directories and will count each
|
||||||
|
symlinked file as a unique file (i.e. unlike how hard links are handled). This
|
||||||
|
is subject to change in later versions.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ static int dir_scan_recurse(const char *name) {
|
||||||
* directory. Assumes we're chdir'ed in the directory in which this item
|
* directory. Assumes we're chdir'ed in the directory in which this item
|
||||||
* resides. */
|
* resides. */
|
||||||
static int dir_scan_item(const char *name) {
|
static int dir_scan_item(const char *name) {
|
||||||
struct stat st;
|
static struct stat st, stl;
|
||||||
int fail = 0;
|
int fail = 0;
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
|
|
@ -204,12 +204,10 @@ static int dir_scan_item(const char *name) {
|
||||||
dir_setlasterr(dir_curpath);
|
dir_setlasterr(dir_curpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(buf_dir->flags & (FF_ERR|FF_EXL)))
|
if(!(buf_dir->flags & (FF_ERR|FF_EXL))) {
|
||||||
stat_to_dir(&st);
|
if(follow_symlinks && S_ISLNK(st.st_mode) && !stat(name, &stl) && !S_ISDIR(stl.st_mode))
|
||||||
|
stat_to_dir(&stl);
|
||||||
if (!(buf_dir->flags & (FF_ERR|FF_EXL)) && follow_symlinks && S_ISLNK(st.st_mode))
|
else
|
||||||
if (!stat(name, &st)) {
|
|
||||||
if (!S_ISDIR(st.st_mode))
|
|
||||||
stat_to_dir(&st);
|
stat_to_dir(&st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue