media/migrations: use a platform-neutral file symlink helper - #549
Open
obodnikov wants to merge 1 commit into
Open
media/migrations: use a platform-neutral file symlink helper#549obodnikov wants to merge 1 commit into
obodnikov wants to merge 1 commit into
Conversation
`tokio::fs::symlink` is exported only on unix, so the three legacy-link call
sites in `media/migrations.rs` do not resolve elsewhere:
error[E0425]: cannot find function `symlink` in module `tokio::fs`
--> src/service/media/migrations.rs:55:16
|
| tokio::fs::symlink(&path, &old_path).await?;
| ^^^^^^^ not found in `tokio::fs`
Every one of them links to a file, and Windows separates that case from linking
to a directory, so this routes them through a small helper that picks the
platform's spelling: `symlink` on unix, `symlink_file` on Windows, and an
`Unsupported` error where there is no equivalent to call. It takes
`impl AsRef<Path>` for both arguments, matching the signature of the tokio
functions it wraps, so the call sites are unchanged apart from the name.
On Windows the call itself can still fail without the privilege to create a
link. That surfaces as the same error a failing `symlink` already returns on
unix, and only under `media_compat_file_link`, which is off by default.
No behaviour change on unix.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
tokio::fs::symlinkis exported only on unix, so the three legacy-link call sites inmedia/migrations.rsdo not resolve elsewhere:Every one of the three links to a file, and Windows separates that case from linking to
a directory, so this routes them through a small helper that picks the platform's
spelling:
It takes
impl AsRef<Path>for both arguments, matching the signature of the tokiofunctions it wraps, so the call sites change only in the name. The third arm keeps
targets with neither spelling compiling rather than trading one unresolved name for
another.
tokio::fs::symlink_metadataandtokio::fs::remove_file, the other two filesystemcalls in this file, are already available on every target.
On the Windows arm. Creating a link there can still fail for want of the privilege
to make one. That surfaces as the same error a failing
symlinkalready returns on unix,and only under
media_compat_file_link, which is off by default and exists forcompatibility with a directory layout that predates the sha256 migration.
No behaviour change on unix. Same class of fix as #526, #527, #528 and #536.
On verification. CI builds Linux only, where this is a no-op both before and after,
so CI cannot demonstrate the change. It was observed building v1.8.3 for
x86_64-pc-windows-msvc, and the error above is reproducible on any host with a one-filecrate that depends on
tokiowith thefsfeature and callstokio::fs::symlink.cargo +nightly fmt --check,cargo checkandcargo clippyon the unix path are cleanbefore and after.
Checklist
cargo fmtand satisfies clippy andrustc lints; any allowed lint is justified by an obvious reason or a
comment.
are noted in the description above. — none; the unix path resolves to
the same
tokio::fs::symlinkcall it made before.src/core/config/mod.rsdoccomments and the regenerated
tuwunel-example.tomlis committed. — n/adocs/. — n/aand my conduct is in line with the Contributor's Covenant and
Tuwunel's Code of Conduct.