webui: apply category on add + allow no category
api_add now forwards the chosen category to the daemon (and fixes a use-after-free reading it from the freed request). Mark issues #3, #8, #9 done in ISSUES.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
b633b7d216
commit
8295b8522c
2 changed files with 14 additions and 4 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
- ✅ Set Location doesn't work, it should also show the current location.
|
- ✅ Set Location doesn't work, it should also show the current location.
|
||||||
- ⬛ I need a way to modify a category (including Uncategorozied).
|
- ⬛ I need a way to modify a category (including Uncategorozied).
|
||||||
- ⬛ Adding a Category means I can't have none selected on adding a torrent.
|
- ✅ Adding a Category means I can't have none selected on adding a torrent.
|
||||||
- ⬛ Category default download location does nothing as changing it doesn't change the download location. Download location should be greyed out by default with the default location shown. Clicking should allow you to change the location. If the location is set it shouldn't change if the category is changed.
|
- ⬛ Category default download location does nothing as changing it doesn't change the download location. Download location should be greyed out by default with the default location shown. Clicking should allow you to change the location. If the location is set it shouldn't change if the category is changed.
|
||||||
- ✅ Automation variables at half window width makes the script unseeable. It should be displayed above the script if the window is to narrow.
|
- ✅ Automation variables at half window width makes the script unseeable. It should be displayed above the script if the window is to narrow.
|
||||||
- ⬛ We need to implement the RSS and Search Tabs.
|
- ⬛ We need to implement the RSS and Search Tabs.
|
||||||
- ⬛ I need to be able to add Tags on adding a torrent.
|
- ⬛ I need to be able to add Tags on adding a torrent.
|
||||||
- ⬛ Categories aren't saved across restart.
|
- ✅ Categories aren't saved across restart.
|
||||||
- ⬛ Pausing a torrent will go back into Downloading and Seeding.
|
- ✅ Pausing a torrent will go back into Downloading and Seeding.
|
||||||
- ⬛ A torrents data could overlap with another existing torrent. This should be blocked to avoid
|
- ⬛ A torrents data could overlap with another existing torrent. This should be blocked to avoid
|
||||||
|
|
@ -1358,11 +1358,16 @@ static void api_add(int fd, const char *body, size_t len) {
|
||||||
const char *data = json_string_value(json_object_get(req, "data"));
|
const char *data = json_string_value(json_object_get(req, "data"));
|
||||||
const char *save_path = json_string_value(json_object_get(req, "savePath"));
|
const char *save_path = json_string_value(json_object_get(req, "savePath"));
|
||||||
/* The UI parses the .torrent client-side and sends a display name; the
|
/* The UI parses the .torrent client-side and sends a display name; the
|
||||||
* daemon only knows the temp upload path, so we keep the name here. */
|
* daemon only knows the temp upload path, so we keep the name here. Copy
|
||||||
|
* out of `req` since it is freed before these are used below. */
|
||||||
const char *display = json_string_value(json_object_get(req, "name"));
|
const char *display = json_string_value(json_object_get(req, "name"));
|
||||||
char display_name[256] = {0};
|
char display_name[256] = {0};
|
||||||
if (display && *display)
|
if (display && *display)
|
||||||
snprintf(display_name, sizeof display_name, "%s", display);
|
snprintf(display_name, sizeof display_name, "%s", display);
|
||||||
|
const char *category = json_string_value(json_object_get(req, "category"));
|
||||||
|
char category_name[256] = {0};
|
||||||
|
if (category && *category)
|
||||||
|
snprintf(category_name, sizeof category_name, "%s", category);
|
||||||
if (!save_path || !*save_path) save_path = ".";
|
if (!save_path || !*save_path) save_path = ".";
|
||||||
if (!source) source = magnet;
|
if (!source) source = magnet;
|
||||||
if ((!source || !*source) && (!data || !*data)) {
|
if ((!source || !*source) && (!data || !*data)) {
|
||||||
|
|
@ -1388,6 +1393,10 @@ static void api_add(int fd, const char *body, size_t len) {
|
||||||
/* Forward the display name so the daemon persists it for restore. */
|
/* Forward the display name so the daemon persists it for restore. */
|
||||||
if (display_name[0])
|
if (display_name[0])
|
||||||
json_object_set_new(params, "name", json_string(display_name));
|
json_object_set_new(params, "name", json_string(display_name));
|
||||||
|
/* An empty category means "Uncategorized"; only forward a real one. The
|
||||||
|
* daemon (spawn_torrent) reads "category" and persists it. */
|
||||||
|
if (category_name[0])
|
||||||
|
json_object_set_new(params, "category", json_string(category_name));
|
||||||
json_t *result = rpc_call_json("add_torrent", params);
|
json_t *result = rpc_call_json("add_torrent", params);
|
||||||
json_decref(params);
|
json_decref(params);
|
||||||
json_decref(req);
|
json_decref(req);
|
||||||
|
|
@ -1397,6 +1406,7 @@ static void api_add(int fd, const char *body, size_t len) {
|
||||||
}
|
}
|
||||||
uint64_t new_id = json_u64(result, "torrent_id");
|
uint64_t new_id = json_u64(result, "torrent_id");
|
||||||
if (display_name[0]) store_set_name(new_id, display_name);
|
if (display_name[0]) store_set_name(new_id, display_name);
|
||||||
|
if (category_name[0]) store_set_category(new_id, category_name);
|
||||||
char id[32];
|
char id[32];
|
||||||
snprintf(id, sizeof id, "%llu", (unsigned long long)new_id);
|
snprintf(id, sizeof id, "%llu", (unsigned long long)new_id);
|
||||||
json_t *reply = json_pack("{s:b,s:s}", "ok", 1, "hash", id);
|
json_t *reply = json_pack("{s:b,s:s}", "ok", 1, "hash", id);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue