Show More
@@ -116,7 +116,12 impl TruncatedTimestamp { | |||
|
116 | 116 | metadata: &fs::Metadata, |
|
117 | 117 | boundary: &Self, |
|
118 | 118 | ) -> io::Result<Option<Self>> { |
|
119 | let mut mtime = Self::for_mtime_of(metadata)?; | |
|
119 | Ok(Self::for_mtime_of(metadata)?.for_reliable_mtime_of_self(boundary)) | |
|
120 | } | |
|
121 | ||
|
122 | /// See [`Self::for_reliable_mtime_of`] | |
|
123 | pub fn for_reliable_mtime_of_self(&self, boundary: &Self) -> Option<Self> { | |
|
124 | let mut new = *self; | |
|
120 | 125 | // If the mtime of the ambiguous file is younger (or equal) to the |
|
121 | 126 | // starting point of the `status` walk, we cannot garantee that |
|
122 | 127 | // another, racy, write will not happen right after with the same mtime |
@@ -126,23 +131,23 impl TruncatedTimestamp { | |||
|
126 | 131 | // mismatch between the current clock and previous file system |
|
127 | 132 | // operation. So mtime more than one days in the future are considered |
|
128 | 133 | // fine. |
|
129 |
let reliable = if |
|
|
134 | let reliable = if self.truncated_seconds == boundary.truncated_seconds | |
|
130 | 135 | { |
|
131 |
|
|
|
132 |
|
|
|
136 | new.second_ambiguous = true; | |
|
137 | self.nanoseconds != 0 | |
|
133 | 138 | && boundary.nanoseconds != 0 |
|
134 |
&& |
|
|
139 | && self.nanoseconds < boundary.nanoseconds | |
|
135 | 140 | } else { |
|
136 | 141 | // `truncated_seconds` is less than 2**31, |
|
137 | 142 | // so this does not overflow `u32`: |
|
138 | 143 | let one_day_later = boundary.truncated_seconds + 24 * 3600; |
|
139 |
|
|
|
140 |
|| |
|
|
144 | self.truncated_seconds < boundary.truncated_seconds | |
|
145 | || self.truncated_seconds > one_day_later | |
|
141 | 146 | }; |
|
142 | 147 | if reliable { |
|
143 |
|
|
|
148 | Some(new) | |
|
144 | 149 | } else { |
|
145 |
|
|
|
150 | None | |
|
146 | 151 | } |
|
147 | 152 | } |
|
148 | 153 |
General Comments 0
You need to be logged in to leave comments.
Login now