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

Symlinks under topgrade.d are ignored #852

Closed
2 of 6 tasks
gifnksm opened this issue Jul 7, 2024 · 0 comments · Fixed by #853
Closed
2 of 6 tasks

Symlinks under topgrade.d are ignored #852

gifnksm opened this issue Jul 7, 2024 · 0 comments · Fixed by #853
Labels
C-bug Something isn't working

Comments

@gifnksm
Copy link
Contributor

gifnksm commented Jul 7, 2024

Erroneous Behavior

Symbolic links under CONFIG_DIR/topgrade.d/ are ignored even if they point to files.

Expected Behavior

The configuration files of the symbolic link destination are included.

Steps to reproduce

$ mkdir -p ~/.config/topgrade.d
$ cat >config.toml <<END
[misc]
no_self_update = true
END
$ ln -s ~/.config/topgrade.d/config.toml config.toml
$ topgrade --log-filter debug
# ~/.config/topgrade.d/config.toml is not included

Possible Cause (Optional)

Additional configuration files are searched in ConfigFile::ensure_topgrade_d().
That function filters entries of the directory by DirEntry::file_type() and FileType::is_file().
DirEntry::file_type() will not traverse symlinks (see std document).
FileType::is_file() returns false for symlinks (see std document).
So, entry.file_type()?.is_file() returns false for symbolic links.

topgrade/src/config.rs

Lines 534 to 543 in 960b14f

for entry in fs::read_dir(dir_to_search)? {
let entry = entry?;
if entry.file_type()?.is_file() {
debug!(
"Found additional (directory) configuration file at {}",
entry.path().display()
);
res.push(entry.path());
}
}

You can use Path::is_file() as follows to follow symbolic links.

entry.path().is_file()

Problem persists without calling from topgrade

  • Yes
  • No

Did you run topgrade through Remote Execution

  • Yes
  • No

If yes, does the issue still occur when you run topgrade directlly in your
remote host

  • Yes
  • No

Configuration file (Optional)

Additional Details

  • Operation System/Version

  • Installation

  • Topgrade version (topgrade -V)

Verbose Output (topgrade -v)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant