Skip to content

Use infohash instead of torrent ID in API URLs#140

Merged
josecelano merged 9 commits intotorrust:developfrom
josecelano:issue-115-replace-id-by-info-hash-in-urlpath-vars
May 8, 2023
Merged

Use infohash instead of torrent ID in API URLs#140
josecelano merged 9 commits intotorrust:developfrom
josecelano:issue-115-replace-id-by-info-hash-in-urlpath-vars

Conversation

@josecelano
Copy link
Copy Markdown
Member

@josecelano josecelano commented May 5, 2023

  • Change endpoint GET /torrent/download/{id} to GET /torrent/download/{infohash}
  • Change endpoint GET /torrent/{id} to GET /torrent/{infohash}
  • Change endpoint PUT /torrent/{id} to PUT /torrent/{infohash}
  • Change endpoint DELETE /torrent/{id} to DELETE /torrent/{infohash}

@josecelano josecelano linked an issue May 5, 2023 that may be closed by this pull request
josecelano added 5 commits May 5, 2023 13:24
We have to start the test env before the condition to skip the test:

```
if !env.provides_a_tracker() {
   println!("test skipped. It requires a tracker to be running.");
   return;
}
```

Itherwise the test is never executed, even when you are using the
shared env:

```
TORRUST_IDX_BACK_E2E_SHARED=true cargo test
```
They will used in a new struct InfoHash.
…ent/download/{infohash}

BREAKING CHANGE: you can not use the odl endpoint enaymore: `GET /torrent/download/{id}`.

You have to use the torrent infohash.
@josecelano josecelano requested review from da2ce7 and mickvandijke May 5, 2023 16:07
@josecelano
Copy link
Copy Markdown
Member Author

Hi @WarmBeer @da2ce7 , I've finished the first endpoint. It should be easy to change the rest of the endpoints. The hardest part is done.

Notice that I've copied the whole InfoHash implementation from the Tracker. At some point, we should publish the bit_torrent mod as an independent package. Form the time being, I've just copied it.

The InfoHash struct uses lowercase hex infohashes, but the database stores them as uppercase. Even if it's not critical I would use always the lowercase version. I have the impression that it's more common.

josecelano added 3 commits May 8, 2023 13:19
Since we are going to change those endpoint, it's convenient to add more
test. Endpoints starting with `torrent/{id}` will be change to use the
infohash instead of the internal torrent id, generated by the database.
BREAKING CHANGE: you cannot use the old endpoints anymore:

- `GET /torrent/{id}`.
- `PUT /torrent/{id}`.
- `DELETE /torrent/{id}`.

New endpoints:

- `GET /torrent/{infohashi`.
- `PUT /torrent/{infohash}`.
- `DELETE /torrent/{infohash}`.
Those files are only realted to `tests\database` tests.
@josecelano
Copy link
Copy Markdown
Member Author

ACK de56be0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Use infohash instead of torrent ID in API URLs

1 participant