diff options
author | Daniel Kamil Kozar <dkk089@gmail.com> | 2017-08-21 13:53:29 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2017-08-21 17:55:05 +0200 |
commit | a6038ff6b95a4ef4522626a35c08a6e0b3a4eda3 (patch) | |
tree | 3e7fb89ef6c6c2a3067450443c413c32020d760b /src | |
parent | e23a4013d6aa5c77fbdbbb36cdef8e90dbf79057 (diff) |
Add a download_shared setting to disable downloading of already shared files
As a bonus, display 'S' when viewing a file list if the given file is already
present in the local shared file list.
Diffstat (limited to 'src')
-rw-r--r-- | src/dl.c | 10 | ||||
-rw-r--r-- | src/doc.h | 6 | ||||
-rw-r--r-- | src/uit_fl.c | 7 | ||||
-rw-r--r-- | src/vars.c | 1 |
4 files changed, 21 insertions, 3 deletions
@@ -602,6 +602,16 @@ void dl_queue_add_fl(guint64 uid, fl_list_t *fl, char *base, GRegex *excl) { ui_mf(NULL, 0, "Ignoring `%s': excluded by regex.", fl->name); return; } + { + // don't download already shared files if download_shared is set to false. + GSList *localfl = fl_local_from_tth(fl->tth); + if(!var_get_bool(0, VAR_download_shared) && fl->hastth && localfl && localfl->data) { + fl_list_t *localf = localfl->data; + ui_mf(NULL, 0, "Ignoring `%s' : already shared as `%s'", fl->name, localf->name); + return; + } + } + char *name = base ? g_build_filename(base, fl->name, NULL) : g_strdup(fl->name); if(fl->isfile) { @@ -404,6 +404,12 @@ static const doc_set_t doc_sets[] = { "Minimum segment size to use when requesting file data from another user." " Set to 0 to disable segmented downloading." }, +{ + "download_shared", 0, "<boolean>", + "Whether to download files which are already present in your share. When this" + " is set to `false', adding already shared files results in a UI message" + " instead of adding the file to the download queue." +}, { "download_slots", 0, "<integer>", "Maximum number of simultaneous downloads." }, diff --git a/src/uit_fl.c b/src/uit_fl.c index 4dbd3cd..3e0db83 100644 --- a/src/uit_fl.c +++ b/src/uit_fl.c @@ -336,11 +336,12 @@ static void draw_row(ui_listing_t *list, GSequenceIter *iter, int row, void *dat mvaddstr(row, 0, ">"); mvaddch(row, 2, fl->isfile && !fl->hastth ? 'H' :' '); + mvaddch(row, 3, fl_local_from_tth(fl->tth) ? 'S' : ' '); - mvaddstr(row, 4, str_formatsize(fl->size)); + mvaddstr(row, 5, str_formatsize(fl->size)); if(!fl->isfile) - mvaddch(row, 17, '/'); - ui_listing_draw_match(list, iter, row, 18, str_offset_from_columns(fl->name, wincols-19)); + mvaddch(row, 18, '/'); + ui_listing_draw_match(list, iter, row, 19, str_offset_from_columns(fl->name, wincols-20)); attroff(iter == list->sel ? UIC(list_select) : UIC(list_default)); } @@ -962,6 +962,7 @@ struct var_t { V(download_exclude, 1,0, f_id, p_regex, su_old, NULL, NULL, NULL)\ V(download_rate, 1,0, f_speed, p_speed, NULL, NULL, NULL, NULL)\ V(download_segment, 1,0, f_download_segment,p_download_segment,NULL, NULL, NULL, g_strdup_printf("%"G_GUINT64_FORMAT, (guint64)DLFILE_CHUNKSIZE))\ + V(download_shared, 1,0, f_bool, p_bool, su_bool, NULL, NULL, "true")\ V(download_slots, 1,0, f_int, p_int, NULL, NULL, s_download_slots,"3")\ V(email, 1,1, f_id, p_id, su_old, NULL, s_hubinfo, NULL)\ V(encoding, 1,1, f_id, p_encoding, su_encoding, NULL, NULL, "UTF-8")\ |