Traverse symlinks when resolving migrations (#2445)

* Traverse symlinks when resolving migrations

When enumerating the source directory seeking migration files, `sqlx`
ignores entries that aren't files. This was previously reported as #614
and fixed in #985 but apparently regressed somewhere along the way. This
commit reintroduces the fix from #985 to the current implementation: use
`std::fs::metadata` instead of `std::fs::DirEntry::metadata`. The former
is documented to traverse symlinks; the latter does not.

* add migrations_symlink test
This commit is contained in:
Tim Geoghegan
2023-06-13 11:21:09 -07:00
committed by GitHub
parent 238a95b0f3
commit 0c8fe729ff
3 changed files with 6 additions and 1 deletions

View File

@@ -24,7 +24,8 @@ impl<'s> MigrationSource<'s> for &'s Path {
let mut migrations = Vec::new();
while let Some(entry) = s.next().await? {
if !entry.metadata.is_file() {
// std::fs::metadata traverses symlinks
if !std::fs::metadata(&entry.path)?.is_file() {
// not a file; ignore
continue;
}