Radish alpha
r
Radicle Job Collaborative Object
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: chain get_mut
✓ CI success Fintan Halpenny committed 2 months ago
commit 4b5adb5c31f70e11953256f48956bdd03662f853
parent 912f25216dc3507c20c0882eaa7d006ac73c9fc5
1 passed (1 total) View logs
1 file changed +16 -15
modified src/lib.rs
@@ -402,15 +402,17 @@ impl Job {
    }

    fn set_log(&mut self, node: NodeId, uuid: Uuid, log: Url, timestamp: cob::Timestamp) -> bool {
-
        let Some(runs) = self.runs.get_mut(&node) else {
-
            return false;
-
        };
-
        let mut updated = false;
-
        runs.0.entry(uuid).and_modify(|run| {
-
            updated = true;
-
            *run = run.clone().set_log(log, timestamp);
-
        });
-
        updated
+
        match self
+
            .runs
+
            .get_mut(&node)
+
            .and_then(|runs| runs.0.get_mut(&uuid))
+
        {
+
            Some(run) => {
+
                run.set_log(log, timestamp);
+
                true
+
            }
+
            None => false,
+
        }
    }

    fn action(&mut self, node: NodeId, action: Action, timestamp: cob::Timestamp) {
@@ -533,12 +535,11 @@ impl Run {
    }

    /// Set the log of the `Run`.
-
    fn set_log(self, log: Url, timestamp: cob::Timestamp) -> Self {
-
        Self {
-
            status: self.status,
-
            log,
-
            timestamp,
-
        }
+
    ///
+
    /// The timestamp is updated to reflect that the run was modified at the given time.
+
    fn set_log(&mut self, log: Url, timestamp: cob::Timestamp) {
+
        self.log = log;
+
        self.timestamp = timestamp;
    }

    /// Return URL for the log of this run.