Skip to content

Posting a new paste can fail on ID collision #209

@mokurin000

Description

@mokurin000

pub async fn post(
State(db): State<Database>,
Json(entry): Json<Entry>,
) -> Result<Json<RedirectResponse>, JsonErrorResponse> {
let id = Id::rand();
let entry: write::Entry = entry.into();
let path = format!("/{}", id.to_url_path(&entry));
db.insert(id, entry).await.map_err(Error::Database)?;
Ok(Json::from(RedirectResponse { path }))
}

We may try to regenerate the id and re-insert in configurable times, avoid potential weird post failure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions