Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: inlude the canonical info hash group in the torrent details response #518

Conversation

josecelano
Copy link
Member

Add to the responses (torrent details and after updating a torrent) the list of info-hashes that belong to the same canonical info-hash. Table torrust_torrent_info_hashes

CREATE TABLE "torrust_torrent_info_hashes" (
	"info_hash"	TEXT NOT NULL,
	"canonical_info_hash"	TEXT NOT NULL,
	"original_is_known"	BOOLEAN NOT NULL,
	PRIMARY KEY("info_hash"),
	FOREIGN KEY("canonical_info_hash") REFERENCES "torrust_torrents"("info_hash") ON DELETE CASCADE
);

New response for torrent details:

{
    "data": {
        "torrent_id": 2,
        "uploader": "admin",
        "info_hash": "0c90fbf036e28370c1ec773401bc7620146b1d48",
        "title": "Test 01",
        "description": "Test 01",
        "category": {
            "id": 5,
            "category_id": 5,
            "name": "software",
            "num_torrents": 1
        },
        "upload_date": "2024-03-05 16:05:00",
        "file_size": 602515,
        "seeders": 0,
        "leechers": 0,
        "files": [
            {
                "path": [
                    "mandelbrot_set_01"
                ],
                "length": 602515,
                "md5sum": null
            }
        ],
        "trackers": [
            "udp://localhost:6969"
        ],
        "magnet_link": "magnet:?xt=urn:btih:0c90fbf036e28370c1ec773401bc7620146b1d48&dn=Test%2001&tr=udp%3A%2F%2Flocalhost%3A6969",
        "tags": [],
        "name": "mandelbrot_set_01",
        "comment": "Mandelbrot Set 01",
        "creation_date": 1687937540,
        "created_by": "Transmission/3.00 (bb6b5a062e)",
        "encoding": "UTF-8",
        "canonical_info_hash_group": [
            "d5eaff5bc75ed274da7c5294de3f6641dc0a90ce",
            "e126f473a9dee89217d7ae5982f9b21490ed2c3f"
        ]
    }
}

Notice the new field canonical_info_hash_group.

Both the d5eaff5bc75ed274da7c5294de3f6641dc0a90ce and e126f473a9dee89217d7ae5982f9b21490ed2c3f were uploaded torrents that produced the same canonical info-hash 0c90fbf036e28370c1ec773401bc7620146b1d48

… API response

```json
{
    "data": {
        "torrent_id": 2,
        "uploader": "admin",
        "info_hash": "0c90fbf036e28370c1ec773401bc7620146b1d48",
        "title": "Test 01",
        "description": "Test 01",
        "category": {
            "id": 5,
            "category_id": 5,
            "name": "software",
            "num_torrents": 1
        },
        "upload_date": "2024-03-05 16:05:00",
        "file_size": 602515,
        "seeders": 0,
        "leechers": 0,
        "files": [
            {
                "path": [
                    "mandelbrot_set_01"
                ],
                "length": 602515,
                "md5sum": null
            }
        ],
        "trackers": [
            "udp://localhost:6969"
        ],
        "magnet_link": "magnet:?xt=urn:btih:0c90fbf036e28370c1ec773401bc7620146b1d48&dn=Test%2001&tr=udp%3A%2F%2Flocalhost%3A6969",
        "tags": [],
        "name": "mandelbrot_set_01",
        "comment": "Mandelbrot Set 01",
        "creation_date": 1687937540,
        "created_by": "Transmission/3.00 (bb6b5a062e)",
        "encoding": "UTF-8",
        "canonical_info_hash_group": [
            "d5eaff5bc75ed274da7c5294de3f6641dc0a90ce",
            "e126f473a9dee89217d7ae5982f9b21490ed2c3f"
        ]
    }
}
```

Notice the new field: `canonical_info_hash_group` at the end of the
JSON.
@josecelano josecelano added this to the v3.0.0 milestone Mar 5, 2024
@josecelano josecelano linked an issue Mar 5, 2024 that may be closed by this pull request
@josecelano josecelano self-assigned this Mar 5, 2024
@josecelano josecelano added Enhancement / Feature Request Something New - User - Enjoyable to Use our Software labels Mar 5, 2024
@josecelano
Copy link
Member Author

ACK 2abb62a

@josecelano josecelano merged commit 61ce771 into torrust:develop Mar 5, 2024
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- User - Enjoyable to Use our Software Enhancement / Feature Request Something New
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include the canonical info-hash group in the torrent details response
1 participant