File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,12 @@ impl File {
59
59
///
60
60
/// If `boundary_directory` is given, non-existing directories will be created automatically and removed in the case of
61
61
/// a rollback. Otherwise the containing directory is expected to exist, even though the resource doesn't have to.
62
+ ///
63
+ /// ### Warning of potential resource leak
64
+ ///
65
+ /// Please note that the underlying file will remain if destructors don't run, as is the case when interrupting the application.
66
+ /// This results in the resource being locked permanently unless the lock file is removed by other means.
67
+ /// See [the crate documentation](crate) for more information.
62
68
pub fn acquire_to_update_resource (
63
69
at_path : impl AsRef < Path > ,
64
70
mode : Fail ,
@@ -80,6 +86,12 @@ impl Marker {
80
86
///
81
87
/// If `boundary_directory` is given, non-existing directories will be created automatically and removed in the case of
82
88
/// a rollback.
89
+ ///
90
+ /// ### Warning of potential resource leak
91
+ ///
92
+ /// Please note that the underlying file will remain if destructors don't run, as is the case when interrupting the application.
93
+ /// This results in the resource being locked permanently unless the lock file is removed by other means.
94
+ /// See [the crate documentation](crate) for more information.
83
95
pub fn acquire_to_hold_resource (
84
96
at_path : impl AsRef < Path > ,
85
97
mode : Fail ,
Original file line number Diff line number Diff line change 1
1
//! git-style registered lock files to make altering resources atomic.
2
2
//!
3
- //! In this model, reads are always atomic and can be performed directly while writes are facilitated by a locking mechanism
4
- //! implemented here.
3
+ //! In this model, reads are always atomic and can be performed directly while writes are facilitated by the locking mechanism
4
+ //! implemented here. Locks are acquired atomically, then written to, to finally atomically overwrite the actual resource.
5
5
//!
6
- //! Lock files mostly `gix-tempfile` with its auto-cleanup and the following:
6
+ //! Lock files are wrapped [ `gix-tempfile`](gix_tempfile)-handles and add the following:
7
7
//!
8
8
//! * consistent naming of lock files
9
9
//! * block the thread (with timeout) or fail immediately if a lock cannot be obtained right away
10
10
//! * commit lock files to atomically put them into the location of the originally locked file
11
11
//!
12
12
//! # Limitations
13
13
//!
14
+ //! * [All limitations of `gix-tempfile`](gix_tempfile) apply. **A highlight of such a limitation is resource leakage
15
+ //! which results in them being permanently locked unless there is user-intervention.**
14
16
//! * As the lock file is separate from the actual resource, locking is merely a convention rather than being enforced.
15
- //! * The limitations of `gix-tempfile` apply.
16
17
#![ deny( missing_docs, rust_2018_idioms, unsafe_code) ]
17
18
19
+ use gix_tempfile:: handle:: { Closed , Writable } ;
18
20
use std:: path:: PathBuf ;
19
21
20
22
pub use gix_tempfile as tempfile;
21
- use gix_tempfile:: handle:: { Closed , Writable } ;
22
23
23
24
const DOT_LOCK_SUFFIX : & str = ".lock" ;
24
25
You can’t perform that action at this time.
0 commit comments