Skip to content

Commit

Permalink
Let btpd remove torrent data by itself instead of calling rm.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmn64k committed Jan 10, 2009
1 parent b5d78b0 commit 4457c12
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions btpd/tlib.c
Expand Up @@ -62,11 +62,22 @@ int
tlib_del(struct tlib *tl) tlib_del(struct tlib *tl)
{ {
char relpath[RELPATH_SIZE]; char relpath[RELPATH_SIZE];
char cmd[PATH_MAX]; char path[PATH_MAX];
DIR *dir;
struct dirent *de;
assert(tl->tp == NULL); assert(tl->tp == NULL);
snprintf(cmd, PATH_MAX, "rm -r torrents/%s", snprintf(path, PATH_MAX, "torrents/%s", bin2hex(tl->hash, relpath, 20));
bin2hex(tl->hash, relpath, 20)); if ((dir = opendir(path)) != NULL) {
system(cmd); while ((de = readdir(dir)) != NULL) {
if (strcmp(".", de->d_name) == 0 || strcmp("..", de->d_name) == 0)
continue;
snprintf(path, PATH_MAX, "torrents/%s/%s", relpath, de->d_name);
remove(path);
}
closedir(dir);
}
snprintf(path, PATH_MAX, "torrents/%s", relpath);
remove(path);
tlib_kill(tl); tlib_kill(tl);
return 0; return 0;
} }
Expand Down

0 comments on commit 4457c12

Please sign in to comment.