Browse Source

This is very much a intermediate commit.

* Load "test" torrent on start.
* Look for content and resume in the right places.
master
Richard Nyberg 19 years ago
parent
commit
db4e9b869d
3 changed files with 12 additions and 8 deletions
  1. +1
    -0
      btpd/main.c
  2. +2
    -2
      btpd/policy_subr.c
  3. +9
    -6
      btpd/torrent.c

+ 1
- 0
btpd/main.c View File

@@ -174,6 +174,7 @@ args_done:
event_init();

btpd_init();
torrent_load("test");

event_dispatch();
btpd_err("Unexpected exit from libevent.\n");


+ 2
- 2
btpd/policy_subr.c View File

@@ -206,7 +206,7 @@ test_hash(struct torrent *tp, uint8_t *hash, unsigned long index)
int bufi;
int err;

err = vopen(&fd, O_RDONLY, "%s", tp->relpath);
err = vopen(&fd, O_RDONLY, "%s/torrent", tp->relpath);
if (err != 0)
btpd_err("test_hash: %s\n", strerror(err));

@@ -231,7 +231,7 @@ static int
ro_fd_cb(const char *path, int *fd, void *arg)
{
struct torrent *tp = arg;
return vopen(fd, O_RDONLY, "%s.d/%s", tp->relpath, path);
return vopen(fd, O_RDONLY, "%s/content/%s", tp->relpath, path);
}

static void


+ 9
- 6
btpd/torrent.c View File

@@ -23,14 +23,14 @@ static int
ro_fd_cb(const char *path, int *fd, void *arg)
{
struct torrent *tp = arg;
return vopen(fd, O_RDONLY, "%s.d/%s", tp->relpath, path);
return vopen(fd, O_RDONLY, "%s/content/%s", tp->relpath, path);
}

static int
wo_fd_cb(const char *path, int *fd, void *arg)
{
struct torrent *tp = arg;
return vopen(fd, O_WRONLY|O_CREAT, "%s.d/%s", tp->relpath, path);
return vopen(fd, O_WRONLY|O_CREAT, "%s/content/%s", tp->relpath, path);
}

static int
@@ -70,14 +70,15 @@ torrent_load3(const char *file, struct metainfo *mi, char *mem, size_t memsiz)
}

static int
torrent_load2(const char *file, struct metainfo *mi)
torrent_load2(const char *name, struct metainfo *mi)
{
int error, ifd;
struct stat sb;
char *mem;
size_t memsiz;
const char *file = name;

if ((error = vopen(&ifd, O_RDWR, "%s.i", file)) != 0) {
if ((error = vopen(&ifd, O_RDWR, "%s/resume", file)) != 0) {
btpd_log(BTPD_L_ERROR, "Error opening %s.i: %s.\n",
file, strerror(error));
return error;
@@ -116,10 +117,12 @@ torrent_load2(const char *file, struct metainfo *mi)
}

int
torrent_load(const char *file)
torrent_load(const char *name)
{
struct metainfo *mi;
int error;
char file[PATH_MAX];
snprintf(file, PATH_MAX, "%s/torrent", name);

if ((error = load_metainfo(file, -1, 0, &mi)) != 0) {
btpd_log(BTPD_L_ERROR, "Couldn't load metainfo file %s: %s.\n",
@@ -133,7 +136,7 @@ torrent_load(const char *file)
}

if (error == 0)
error = torrent_load2(file, mi);
error = torrent_load2(name, mi);

if (error != 0) {
clear_metainfo(mi);


Loading…
Cancel
Save