MCPcopy Create free account
hub / github.com/archlinux/alpm / file_content_updated

Method file_content_updated

dev-scripts/src/sync/mirror/rsync_changes.rs:146–187  ·  view source on GitHub ↗

Check if file content was changed in such a way that it should be extracted again. Returns `Ok(Some(path))`, where `path` points to the file if there were changes. Otherwise `Ok(None)`. This does **not** consider the following to be "relevant" changes: - Directory creation or other ["local changes" as defined by rsync](https://man.archlinux.org/man/rsync.1#o~61). - Sending to remote. This should

(&self)

Source from the content-addressed store, hash-verified

144 /// - Holds a non-deletion message from rsync.
145 /// - Reports a change to a non-file object. See [`PathKind`].
146 pub(crate) fn file_content_updated(&self) -> Result<Option<&Path>, Error> {
147 use Report::*;
148
149 match self {
150 // a file was changed
151 PathChange {
152 change_kind: ChangeKind::Received | ChangeKind::Hardlink,
153 path_kind: PathKind::File,
154 path,
155 } => Ok(Some(path)),
156 // a non-file path was changed
157 PathChange {
158 change_kind: ChangeKind::Received | ChangeKind::Hardlink,
159 path_kind,
160 path,
161 } => Err(Error::RsyncReport {
162 message: format!(
163 "Unexpected path kind {path_kind:?} in rsync change list for {path:?}"
164 ),
165 }),
166 // something was sent to the remote
167 PathChange {
168 change_kind: ChangeKind::Sent,
169 path,
170 ..
171 } => {
172 warn!(
173 "Path '{path:?}' reported as changed on the remote host, this should not happen",
174 );
175 Ok(None)
176 }
177 // a message other than deletion was returned
178 Message(msg) if !msg.as_bytes().starts_with(b"deleting") => Err(Error::RsyncReport {
179 message: format!(
180 "Message found while looking for changes:\n{}",
181 msg.to_string_lossy()
182 ),
183 }),
184 // all other cases are considered "unchanged"
185 _ => Ok(None),
186 }
187 }
188}
189
190#[cfg(test)]

Callers 2

sync_remote_databasesMethod · 0.80
download_packagesMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected