Skip to content

Commit

Permalink
Update to rustix 0.38 and update MSRV to 1.63
Browse files Browse the repository at this point in the history
  • Loading branch information
sdroege committed Jul 3, 2023
1 parent 1cff81e commit c1bbc08
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
rust-version:
- nightly
- stable
- "1.48"
- "1.63"
os:
- ubuntu-latest
- windows-latest
Expand All @@ -27,12 +27,6 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
# Workaround link failures if XCode 14 is combined with Rust <= 1.53
- name: Downgrade to XCode 13
if: ${{ matrix.os == 'macos-latest' && matrix.rust-version == '1.48' }}
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '13'
- name: Build
run: cargo build
- name: Test
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
]
documentation = "https://docs.rs/tempfile"
edition = "2018"
rust-version = "1.48"
rust-version = "1.63"
homepage = "https://stebalien.com/projects/tempfile-rs/"
keywords = ["tempfile", "tmpfile", "filesystem"]
license = "MIT OR Apache-2.0"
Expand All @@ -21,7 +21,7 @@ cfg-if = "1"
fastrand = "2.0.0"

[target.'cfg(any(unix, target_os = "wasi"))'.dependencies]
rustix = { version = "0.37.11", features = ["fs"] }
rustix = { version = "0.38", features = ["fs"] }

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.48"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ patterns and surprisingly difficult to implement securely).
Usage
-----

Minimum required Rust version: 1.48.0
Minimum required Rust version: 1.63.0

Add this to your `Cargo.toml`:

Expand Down
10 changes: 5 additions & 5 deletions src/file/imp/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::util;
use std::path::Path;

#[cfg(not(target_os = "redox"))]
use rustix::fs::{cwd, linkat, renameat, unlinkat, AtFlags};
use rustix::fs::{CWD, linkat, renameat, unlinkat, AtFlags};

pub fn create_named(path: &Path, open_options: &mut OpenOptions) -> io::Result<File> {
open_options.read(true).write(true).create_new(true);
Expand Down Expand Up @@ -103,7 +103,7 @@ pub fn reopen(_file: &File, _path: &Path) -> io::Result<File> {
#[cfg(not(target_os = "redox"))]
pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<()> {
if overwrite {
renameat(cwd(), old_path, cwd(), new_path)?;
renameat(CWD, old_path, CWD, new_path)?;
} else {
// On Linux, use `renameat_with` to avoid overwriting an existing name,
// if the kernel and the filesystem support it.
Expand All @@ -115,7 +115,7 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<

static NOSYS: AtomicBool = AtomicBool::new(false);
if !NOSYS.load(Relaxed) {
match renameat_with(cwd(), old_path, cwd(), new_path, RenameFlags::NOREPLACE) {
match renameat_with(CWD, old_path, CWD, new_path, RenameFlags::NOREPLACE) {
Ok(()) => return Ok(()),
Err(Errno::NOSYS) => NOSYS.store(true, Relaxed),
Err(Errno::INVAL) => {}
Expand All @@ -127,9 +127,9 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<
// Otherwise use `linkat` to create the new filesystem name, which
// will fail if the name already exists, and then `unlinkat` to remove
// the old name.
linkat(cwd(), old_path, cwd(), new_path, AtFlags::empty())?;
linkat(CWD, old_path, CWD, new_path, AtFlags::empty())?;
// Ignore unlink errors. Can we do better?
let _ = unlinkat(cwd(), old_path, AtFlags::empty());
let _ = unlinkat(CWD, old_path, AtFlags::empty());
}
Ok(())
}
Expand Down

0 comments on commit c1bbc08

Please sign in to comment.