Skip to content

Commit a8b227e

Browse files
committed
doc: Improve documentation to make possibility of leaks more clear (#1026)
1 parent 14e0763 commit a8b227e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

gix-tempfile/src/handle.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ impl Handle<Closed> {
6969
///
7070
/// Depending on the `directory` configuration, intermediate directories will be created, and depending on `cleanup` empty
7171
/// intermediate directories will be removed.
72+
///
73+
/// ### Warning of potential leaks
74+
///
75+
/// Without [signal handlers](crate::signal) installed, tempfiles will remain once a termination
76+
/// signal is encountered as destructors won't run. See [the top-level documentation](crate) for more.
7277
pub fn at(path: impl AsRef<Path>, directory: ContainingDirectory, cleanup: AutoRemove) -> io::Result<Self> {
7378
Ok(Handle {
7479
id: Handle::<()>::at_path(path.as_ref(), directory, cleanup, Mode::Closed)?,
@@ -92,6 +97,11 @@ impl Handle<Writable> {
9297
///
9398
/// Depending on the `directory` configuration, intermediate directories will be created, and depending on `cleanup` empty
9499
/// intermediate directories will be removed.
100+
///
101+
/// ### Warning of potential leaks
102+
///
103+
/// Without [signal handlers](crate::signal) installed, tempfiles will remain once a termination
104+
/// signal is encountered as destructors won't run. See [the top-level documentation](crate) for more.
95105
pub fn at(path: impl AsRef<Path>, directory: ContainingDirectory, cleanup: AutoRemove) -> io::Result<Self> {
96106
Ok(Handle {
97107
id: Handle::<()>::at_path(path.as_ref(), directory, cleanup, Mode::Writable)?,
@@ -102,6 +112,11 @@ impl Handle<Writable> {
102112
/// Create a registered tempfile within `containing_directory` with a name that won't clash, and clean it up as specified with `cleanup`.
103113
/// Control how to deal with intermediate directories with `directory`.
104114
/// The temporary file is opened and can be written to using the [`with_mut()`][Handle::with_mut()] method.
115+
///
116+
/// ### Warning of potential leaks
117+
///
118+
/// Without [signal handlers](crate::signal) installed, tempfiles will remain once a termination
119+
/// signal is encountered as destructors won't run. See [the top-level documentation](crate) for more.
105120
pub fn new(
106121
containing_directory: impl AsRef<Path>,
107122
directory: ContainingDirectory,

gix-tempfile/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
//!
1010
//! ### Initial Setup
1111
//!
12-
//! As no handlers for `TERMination` are installed, it is required to call [`signal::setup()`] before creating the first tempfile.
13-
//! This also allows to control how `git-tempfiles` integrates with other handlers under application control.
12+
//! As no handlers for `TERMination` are installed, it is required to call [`signal::setup()`] before creating
13+
//! the first tempfile. This also allows to control how this crate integrates with
14+
//! other handlers under application control.
1415
//!
1516
//! As a general rule of thumb, use `Default::default()` as argument to emulate the default behaviour and
1617
//! abort the process after cleaning temporary files. Read more about options in [`signal::handler::Mode`].
@@ -23,7 +24,7 @@
2324
//! * The application is performing a write operation on the tempfile when a signal arrives, preventing this tempfile to be removed,
2425
//! but not others. Any other operation dealing with the tempfile suffers from the same issue.
2526
//!
26-
//! [signal-hook]: https://docs.rs/signal-hook
27+
//! [`signal-hook`]: https://docs.rs/signal-hook
2728
//!
2829
//! ## Feature Flags
2930
#![cfg_attr(

0 commit comments

Comments
 (0)