Fixing the "old file optimisation" in record, after the move to parallelisable records

[?]
Apr 24, 2021, 6:50 AM
F6V27C3M7GZHBHXMGAZMYO5XGWDYYNNIF2HLDE2VPNHTEVDSYGVQC

Dependencies

  • [2] 7MNTFTDF Exit with an error when a change could not be signed
  • [3] I24UEJQL Various post-fire fixes
  • [4] YN63NUZO Sanakirja 1.0
  • [5] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [6] DJYHARZ7 Skipping old files when recording
  • [7] I2D35LLF More accurate recording of modification time
  • [8] RXNT67OT Sanakirja version, and removing an unwrap
  • [9] VNBLGT6G Do not output unmodified files when resetting (fix)
  • [10] KWAGWB73 Adding extra dependencies from the config file
  • [11] IIV3EL2X Cleanup, formatting, and fixing the Git feature
  • [12] I52XSRUH Massive cleanup, and simplification
  • [13] GP5AAWEK Do not touch the channel if the user does not want to record
  • [14] MFTN7GBW Pre-tags cleanup + fast Sanakirja
  • [15] JL4WKA5P Implement the Sanakirja concurrency model in a cross-process way
  • [16] G6S6PWZE Do not touch the channel if this is a partial record
  • [17] VE2UWMW4 Trying to fix channel touch
  • [18] YDTN6BGI Touch the channel if no file was changed

Change contents

  • replacement in pijul/src/commands/record.rs at line 135
    [4.104255][3.13303:13376](),[4.95][4.104315:104455](),[4.109][4.104315:104455](),[3.13376][4.104315:104455](),[4.104315][4.104315:104455](),[4.104455][2.0:704]()
    if let Some((txn, mut change, updates, hash, oldest)) = result {
    let hash = hash.unwrap();
    if sign {
    let mut key_path = dirs_next::home_dir().unwrap().join(".ssh");
    match sign_hash(&mut key_path, hash).await? {
    Some((pk, signature)) if !signature.is_empty() => {
    let sig = toml::Value::try_from(vec![Signature {
    public_key: pk,
    timestamp: change.header.timestamp,
    signature,
    }])?;
    let mut toml = toml::map::Map::new();
    toml.insert("signatures".to_string(), sig);
    change.unhashed = Some(toml.into());
    let hash2 = repo.changes.save_change(&change).unwrap();
    assert_eq!(hash2, hash);
    [4.104255]
    [2.704]
    match result {
    Either::A((txn, mut change, updates, hash, oldest)) => {
    let hash = hash.unwrap();
    if sign {
    let mut key_path = dirs_next::home_dir().unwrap().join(".ssh");
    match sign_hash(&mut key_path, hash).await? {
    Some((pk, signature)) if !signature.is_empty() => {
    let sig = toml::Value::try_from(vec![Signature {
    public_key: pk,
    timestamp: change.header.timestamp,
    signature,
    }])?;
    let mut toml = toml::map::Map::new();
    toml.insert("signatures".to_string(), sig);
    change.unhashed = Some(toml.into());
    let hash2 = repo.changes.save_change(&change).unwrap();
    assert_eq!(hash2, hash);
    }
    _ => {
    bail!("Could not sign the change");
    }
  • edit in pijul/src/commands/record.rs at line 157
    [2.726][2.726:835]()
    _ => {
    bail!("Could not sign the change");
    }
  • replacement in pijul/src/commands/record.rs at line 158
    [4.105101][4.105101:105115](),[4.105115][3.13377:13552](),[3.13552][4.10252:10329](),[4.10252][4.10252:10329](),[4.10329][4.105191:105252](),[4.105191][4.105191:105252](),[4.298][4.0:45](),[4.45][4.53:82](),[4.298][4.53:82](),[4.82][4.0:529]()
    }
    let mut txn = if let Ok(txn) = Arc::try_unwrap(txn) {
    txn.into_inner().unwrap()
    } else {
    unreachable!()
    };
    txn.apply_local_change(&mut channel, &change, &hash, &updates)?;
    writeln!(stdout, "Hash: {}", hash.to_base32())?;
    debug!("oldest = {:?}", oldest);
    if no_prefixes {
    let mut oldest = oldest
    .duration_since(std::time::SystemTime::UNIX_EPOCH)
    .unwrap()
    .as_secs() as u64;
    if oldest == 0 {
    // If no diff was done at all, it means that no
    // existing file changed since last time (some
    // files may have been added, deleted or moved,
    // but `touch` isn't about those).
    oldest = std::time::SystemTime::now()
    [4.105101]
    [4.529]
    let mut txn = if let Ok(txn) = Arc::try_unwrap(txn) {
    txn.into_inner().unwrap()
    } else {
    unreachable!()
    };
    txn.apply_local_change(&mut channel, &change, &hash, &updates)?;
    writeln!(stdout, "Hash: {}", hash.to_base32())?;
    debug!("oldest = {:?}", oldest);
    if no_prefixes {
    let mut oldest = oldest
  • edit in pijul/src/commands/record.rs at line 171
    [4.681]
    [4.681]
    if oldest == 0 {
    // If no diff was done at all, it means that no
    // existing file changed since last time (some
    // files may have been added, deleted or moved,
    // but `touch` isn't about those).
    oldest = std::time::SystemTime::now()
    .duration_since(std::time::SystemTime::UNIX_EPOCH)
    .unwrap()
    .as_secs() as u64;
    }
    txn.touch_channel(&mut *channel.write()?, Some(oldest));
  • replacement in pijul/src/commands/record.rs at line 183
    [4.699][3.13553:13626]()
    txn.touch_channel(&mut *channel.write()?, Some(oldest));
    [4.699]
    [4.158]
    txn.commit()?;
    }
    Either::B(txn) => {
    if no_prefixes {
    let mut txn = if let Ok(txn) = Arc::try_unwrap(txn) {
    txn.into_inner().unwrap()
    } else {
    unreachable!()
    };
    txn.touch_channel(&mut *channel.write()?, None);
    txn.commit()?;
    }
    writeln!(stderr, "Nothing to record")?;
  • edit in pijul/src/commands/record.rs at line 197
    [4.172][4.105252:105279](),[4.370][4.105252:105279](),[4.105252][4.105252:105279](),[4.6369][4.105279:105296](),[4.105279][4.105279:105296](),[4.315][4.105296:105348](),[4.713][4.105296:105348](),[4.105296][4.105296:105348]()
    txn.commit()?;
    } else {
    writeln!(stderr, "Nothing to record")?;
  • replacement in pijul/src/commands/record.rs at line 248
    [4.106731][4.106731:106748]()
    Option<(
    [4.106731]
    [3.13881]
    Either<(
  • replacement in pijul/src/commands/record.rs at line 254
    [4.749][4.106865:106877](),[4.2303][4.106865:106877](),[4.106865][4.106865:106877]()
    )>,
    [4.749]
    [4.106877]
    ), Arc<RwLock<T>>>,
  • replacement in pijul/src/commands/record.rs at line 305
    [4.107578][3.14379:14615](),[3.14615][4.224:251](),[4.224][4.224:251](),[4.251][4.107578:107607](),[4.107578][4.107578:107607]()
    let mut txn = if let Ok(txn) = Arc::try_unwrap(txn) {
    txn.into_inner().unwrap()
    } else {
    unreachable!()
    };
    txn.touch_channel(&mut *channel.write()?, None);
    txn.commit()?;
    return Ok(None);
    [4.107578]
    [4.107607]
    return Ok(Either::B(txn));
  • replacement in pijul/src/commands/record.rs at line 380
    [3.15141][4.750:768](),[4.109803][4.750:768]()
    Ok(Some((
    [3.15141]
    [4.496]
    Ok(Either::A((
  • edit in pijul/src/commands/record.rs at line 390
    [4.109867]
    [4.109867]
    enum Either<A, B> {
    A(A),
    B(B)
    }
  • replacement in libpijul/src/record.rs at line 154
    [3.43296][3.43296:43376]()
    result.oldest_change = result.oldest_change.min(rec.oldest_change);
    [3.43296]
    [3.43376]
    if result.oldest_change == std::time::UNIX_EPOCH
    || (rec.oldest_change > std::time::UNIX_EPOCH
    && rec.oldest_change < result.oldest_change)
    {
    result.oldest_change = rec.oldest_change
    }