Skip to content

Commit

Permalink
Traverse symlinks when resolving migrations
Browse files Browse the repository at this point in the history
When enumerating the source directory seeking migration files, `sqlx`
ignores entries that aren't files. This was previously reported as launchbadge#614
and fixed in launchbadge#985 but apparently regressed somewhere along the way. This
commit reintroduces the fix from launchbadge#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.
  • Loading branch information
tgeoghegan committed Apr 5, 2023
1 parent 4f1ac1d commit 115fa31
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sqlx-core/src/migrate/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 115fa31

Please sign in to comment.