summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard Nyberg <rnyberg@murmeldjur.se>2007-02-24 21:49:31 +0000
committerRichard Nyberg <rnyberg@murmeldjur.se>2007-02-24 21:49:31 +0000
commit02733b16ecd03a65fd76c551b06df879b45d6bb6 (patch)
tree882a43e69f107eea5687c946de80cd4198aef912
parente117d81cf3a73089bd6c8ce2fb69a70411fd7d91 (diff)
downloadbtpd-02733b16ecd03a65fd76c551b06df879b45d6bb6.tar.gz
btpd-02733b16ecd03a65fd76c551b06df879b45d6bb6.zip
Get rid of tp->relpath.
-rw-r--r--btpd/tlib.c9
-rw-r--r--btpd/torrent.c1
-rw-r--r--btpd/torrent.h1
3 files changed, 7 insertions, 4 deletions
diff --git a/btpd/tlib.c b/btpd/tlib.c
index 93b1df6..1c42d9f 100644
--- a/btpd/tlib.c
+++ b/btpd/tlib.c
@@ -328,8 +328,10 @@ tlib_load_resume(struct tlib *tl, unsigned nfiles, struct file_time_size *fts,
 {
     int err, ver;
     FILE *fp;
+    char relpath[RELPATH_SIZE];
+    bin2hex(tl->hash, relpath, 20);
 
-    if ((err = vfopen(&fp, "r" , "torrents/%s/resume", tl->tp->relpath)) != 0)
+    if ((err = vfopen(&fp, "r" , "torrents/%s/resume", relpath)) != 0)
         return err;
 
     if (fscanf(fp, "%d\n", &ver) != 1)
@@ -363,7 +365,10 @@ tlib_save_resume(struct tlib *tl, unsigned nfiles, struct file_time_size *fts,
 {
     int err;
     FILE *fp;
-    if ((err = vfopen(&fp, "wb", "torrents/%s/resume", tl->tp->relpath)) != 0)
+    char relpath[RELPATH_SIZE];
+    bin2hex(tl->hash, relpath, 20);
+
+    if ((err = vfopen(&fp, "wb", "torrents/%s/resume", relpath)) != 0)
         return;
     fprintf(fp, "%d\n", 1);
     for (int i = 0; i < nfiles; i++)
diff --git a/btpd/torrent.c b/btpd/torrent.c
index f9c9e86..e97a245 100644
--- a/btpd/torrent.c
+++ b/btpd/torrent.c
@@ -127,7 +127,6 @@ torrent_start(struct tlib *tl)
 
     tp = btpd_calloc(1, sizeof(*tp));
     tp->tl = tl;
-    bcopy(relpath, tp->relpath, RELPATH_SIZE);
     tp->files = mi_files(mi);
     tp->nfiles = mi_nfiles(mi);
     if (tp->files == NULL)
diff --git a/btpd/torrent.h b/btpd/torrent.h
index 5f3116a..c9d11e5 100644
--- a/btpd/torrent.h
+++ b/btpd/torrent.h
@@ -14,7 +14,6 @@ enum torrent_state {
 struct torrent {
     struct tlib *tl;
 
-    char relpath[RELPATH_SIZE];
     enum torrent_state state;
     int delete;