pijul: GET change works, now clone and pull works too Pull/Clone depends on routes already implemented for content negotiation, and thus was easy to get working. Again, this route lacks authentication and authorization.

zj
Sep 17, 2021, 8:26 AM
HOAKL56VHB543H2MWVHLBI3R7NPW3LLVJ5X5LZ4DVXIYGIMFOXJQC

Dependencies

  • [2] WSHUT37C pijul: Pushes now work completely While still missing authn and authz, the flow of pushing now works. This enables validation of at least storing data. Later changes will show the data on the project page.
  • [3] DSWQKJRH users: Introduce User guard for routes Rockets guards are very powerful to disallow users for certain routes. This far this wasn't implemented, and allowed no-one other than the first user to sign up. This change introduces the User guard and employs it for a few routes. The guard works by checking the encrypted cookie for the user_id, and perform a database lookup on it.
  • [4] W2ZEVC64 pijul: HTTP push now works While missing Auth{n,z}, one can now push to the main channel. The patches are stored and normal Pijul command can be run in the repository on disk.
  • [5] FS2NWBVN pijul: Start of push/pull work This change includes one API endpoint, .pijul. It allows for getting a channels remote ID. A lot of plumbing around repositories is added too, from init to opening pristine and actions like it.

Change contents

  • edit in src/pijul.rs at line 4
    [3.490]
    [3.490]
    use rocket::fs::NamedFile;
  • edit in src/pijul.rs at line 44
    [3.1046][2.61:89]()
    println!("changelist");
  • replacement in src/pijul.rs at line 105
    [2.1092][2.1092:1115]()
    struct IdentitiesReq {
    [2.1092]
    [2.1115]
    struct Identities {
  • replacement in src/pijul.rs at line 110
    [2.1191][2.1191:1232]()
    #[derive(Serialize)]
    struct Identities {
    [2.1191]
    [2.1232]
    #[derive(Serialize, FromForm)]
    struct IdentitieRes {
  • replacement in src/pijul.rs at line 117
    [2.1321][2.1321:1518]()
    #[get("/<org_path>/<proj_path>/.pijul?<id_req>", rank = 3)]
    fn identities(org_path: String, proj_path: String, id_req: IdentitiesReq) -> Json<Identities> {
    println!("{:?}", id_req.identities);
    [2.1321]
    [2.1518]
    #[get("/<org_path>/<proj_path>/.pijul?<identities>", rank = 4)]
    fn identities(org_path: String, proj_path: String, identities: Identities) -> Json<IdentitieRes> {
    Json(IdentitieRes { id: vec![], rev: 0 })
    }
    #[get("/<org_path>/<proj_path>/.pijul?<change>", rank = 3)]
    async fn change(
    db: &State<Database>,
    repoman: &State<RepoMan>,
    org_path: String,
    proj_path: String,
    change: String,
    ) -> Option<NamedFile> {
    let p = projects::find(db, org_path, proj_path).await?;
  • replacement in src/pijul.rs at line 132
    [2.1519][2.1519:1563]()
    Json(Identities { id: vec![], rev: 0 })
    [2.1519]
    [2.1563]
    let hash = crate::models::pijul::changestores::Changestore::hash_from_string(change)?;
    let repo = p.repository(&repoman.storage_root).ok()?;
    let path = repo.changestore().change_file(hash);
    NamedFile::open(path).await.ok()
  • replacement in src/pijul.rs at line 140
    [3.1310][2.1567:1621]()
    routes![remote_id, changelist, apply, identities]
    [3.1310]
    [3.1334]
    routes![remote_id, changelist, apply, identities, change]
  • edit in src/models/pijul/repositories.rs at line 150
    [3.3516][2.2778:2856]()
    println!("loaded channel, changes for: {}, from: {}", channel, from);
  • edit in src/models/pijul/repositories.rs at line 151
    [3.3569][2.2857:2895]()
    println!("found change");
  • edit in src/models/pijul/repositories.rs at line 156
    [3.1387][2.2936:3008]()
    println!("{}.{}.{}", offset, h.to_base32(), m.to_base32());