瀏覽代碼

Make the del command work for active torrents too.

master
Richard Nyberg 18 年之前
父節點
當前提交
a087071b45
共有 3 個文件被更改,包括 14 次插入7 次删除
  1. +11
    -7
      btpd/cli_if.c
  2. +2
    -0
      btpd/torrent.c
  3. +1
    -0
      btpd/torrent.h

+ 11
- 7
btpd/cli_if.c 查看文件

@@ -291,8 +291,8 @@ cmd_del(struct cli *cli, int argc, const char *args)
if (argc != 1)
return IPC_COMMERR;

int ret;
struct tlib *tl;
enum ipc_err code = IPC_OK;
if (benc_isstr(args) && benc_strlen(args) == 20)
tl = tlib_by_hash(benc_mem(args, NULL, NULL));
else if (benc_isint(args))
@@ -301,13 +301,17 @@ cmd_del(struct cli *cli, int argc, const char *args)
return IPC_COMMERR;

if (tl == NULL)
code = IPC_ENOTENT;
else if (tl->tp != NULL)
code = IPC_ETACTIVE;
else
tlib_del(tl);
ret = write_code_buffer(cli, IPC_ENOTENT);
else {
ret = write_code_buffer(cli, IPC_OK);
if (tl->tp != NULL) {
tl->tp->delete = 1;
torrent_stop(tl->tp);
} else
tlib_del(tl);
}

return write_code_buffer(cli, code);
return ret;
}

static int


+ 2
- 0
btpd/torrent.c 查看文件

@@ -160,6 +160,8 @@ torrent_kill(struct torrent *tp)
net_kill(tp);
cm_kill(tp);
tp->tl->tp = NULL;
if (tp->delete)
tlib_del(tp->tl);
mi_free_files(tp->nfiles, tp->files);
free(tp);
if (m_ntorrents == 0)


+ 1
- 0
btpd/torrent.h 查看文件

@@ -15,6 +15,7 @@ struct torrent {

char relpath[RELPATH_SIZE];
enum torrent_state state;
int delete;

struct content *cm;
struct tracker *tr;


Loading…
取消
儲存