Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Stebalien/tempfile
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.18.0
Choose a base ref
...
head repository: Stebalien/tempfile
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.19.0
Choose a head ref
  • 4 commits
  • 6 files changed
  • 1 contributor

Commits on Mar 6, 2025

  1. chore: remove cfg-if dependency (#338)

    It's tiny, but we dont' really need it so we might as well trim our
    dependencies down a bit.
    Stebalien authored Mar 6, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    RicePatrick Patrick Rice
    Copy the full SHA
    35c204d View commit details

Commits on Mar 14, 2025

  1. ci: downgrade once-cell on old rustc versions (#342)

    I'm doing this in CI instead of in the Cargo.toml file because I don't
    want to force users of newer rustc versions to use old versions of
    `once_cell`. Ironically, I only depend on `once_cell` to support ancient
    rust versions in the first place.
    Stebalien authored Mar 14, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    RicePatrick Patrick Rice
    Copy the full SHA
    c2d16b3 View commit details
  2. feat(windows): add a feature to immediate tempfile deletion (#340)

    This adds a feature making it possible to disable the immediate deletion
    of unnamed temporary files on windows (introduced in 461369f).
    Hopefully, this will fix #339. If so, I'll revert 461369f entirely.
    Stebalien authored Mar 14, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    RicePatrick Patrick Rice
    Copy the full SHA
    61b4283 View commit details
  3. chore: release v3.19.0

    Stebalien committed Mar 14, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    svanharmelen Sander van Harmelen
    Copy the full SHA
    42fff68 View commit details
Showing with 30 additions and 22 deletions.
  1. +5 −0 .github/workflows/ci.yml
  2. +5 −0 CHANGELOG.md
  3. +4 −2 Cargo.toml
  4. +9 −12 src/file/imp/mod.rs
  5. +6 −8 src/file/imp/unix.rs
  6. +1 −0 src/file/imp/windows.rs
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -41,6 +41,11 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
- name: Generating the Cargo.lock
run: cargo generate-lockfile
- name: Downgrading once_cell
if: matrix.rust-version == 1.63
run: cargo update -p once_cell --precise 1.20.3
- name: Build
run: cargo build
- name: Test
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 3.19.0

- Remove direct dependency on `cfg-if`. It's still in the tree, but we didn't really need to use it in this crate.
- Add an unstable feature (`unstable-windows-keep-open-tempfile`) to test a potential fix to #339.

## 3.18.0

- Update `rustix` to 1.0.0.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tempfile"
version = "3.18.0"
version = "3.19.0"
authors = [
"Steven Allen <steven@stebalien.com>",
"The Rust Project Developers",
@@ -17,7 +17,6 @@ repository = "https://github.com/Stebalien/tempfile"
description = "A library for managing temporary files and directories."

[dependencies]
cfg-if = "1"
fastrand = "2.1.1"
# Not available in stdlib until 1.70, but we support 1.63 to support Debian stable.
once_cell = { version = "1.19.0", default-features = false, features = ["std"] }
@@ -41,3 +40,6 @@ doc-comment = "0.3"
[features]
default = ["getrandom"]
nightly = []
# Disables immediate deletion of newly opened tempfiles on windows, instead relying on the old
# "delete on close" behavior. This will hopefully fix #339.
unstable-windows-keep-open-tempfile = []
21 changes: 9 additions & 12 deletions src/file/imp/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
cfg_if::cfg_if! {
if #[cfg(any(unix, target_os = "redox", target_os = "wasi"))] {
mod unix;
pub use self::unix::*;
} else if #[cfg(windows)] {
mod windows;
pub use self::windows::*;
} else {
mod other;
pub use self::other::*;
}
}
#[cfg_attr(any(unix, target_os = "redox", target_os = "wasi"), path = "unix.rs")]
#[cfg_attr(windows, path = "windows.rs")]
#[cfg_attr(
not(any(unix, target_os = "redox", target_os = "wasi", windows)),
path = "other.rs"
)]
mod platform;

pub use self::platform::*;
14 changes: 6 additions & 8 deletions src/file/imp/unix.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
use std::ffi::OsStr;
use std::fs::{self, File, OpenOptions};
use std::io;
cfg_if::cfg_if! {
if #[cfg(not(target_os = "wasi"))] {
use std::os::unix::fs::MetadataExt;
} else {
#[cfg(feature = "nightly")]
use std::os::wasi::fs::MetadataExt;
}
}

use crate::util;
use std::path::Path;

@@ -88,6 +81,11 @@ fn create_unix(dir: &Path) -> io::Result<File> {

#[cfg(any(not(target_os = "wasi"), feature = "nightly"))]
pub fn reopen(file: &File, path: &Path) -> io::Result<File> {
#[cfg(not(target_os = "wasi"))]
use std::os::unix::fs::MetadataExt;
#[cfg(target_os = "wasi")]
use std::os::wasi::fs::MetadataExt;

let new_file = OpenOptions::new().read(true).write(true).open(path)?;
let old_meta = file.metadata()?;
let new_meta = new_file.metadata()?;
1 change: 1 addition & 0 deletions src/file/imp/windows.rs
Original file line number Diff line number Diff line change
@@ -76,6 +76,7 @@ pub fn create(dir: &Path) -> io::Result<File> {
.open(path)?;
// Attempt to delete the file by-handle. If this fails, do nothing; the file will be
// deleted on close anyways.
#[cfg(not(feature = "unstable-windows-keep-open-tempfile"))]
let _ = delete_open_file(&f);
Ok(f)
},