diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cache.c | 9 | ||||
-rw-r--r-- | src/cache.h | 1 | ||||
-rw-r--r-- | src/capi.c | 16 |
3 files changed, 14 insertions, 12 deletions
diff --git a/src/cache.c b/src/cache.c index 302e9bda..fe2511d1 100644 --- a/src/cache.c +++ b/src/cache.c @@ -999,7 +999,7 @@ static void Cache_auth_entry(CacheEntry_t *entry, BrowserWindow *bw) * Check whether a URL scheme is downloadable. * Return: 1 enabled, 0 disabled. */ -static int Cache_download_enabled(const DilloUrl *url) +int a_Cache_download_enabled(const DilloUrl *url) { if (!dStrcasecmp(URL_SCHEME(url), "http") || !dStrcasecmp(URL_SCHEME(url), "https") || @@ -1035,7 +1035,8 @@ typedef struct { DilloUrl *url; } Cache_savelink_t; -/* Save link from behind a timeout so that Cache_process_queue() can +/* + * Save link from behind a timeout so that Cache_process_queue() can * get on with its work. */ static void Cache_savelink_cb(void *vdata) @@ -1198,8 +1199,10 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) /* Abort the entry, remove it from cache, and maybe offer download. */ DilloUrl *url = a_Url_dup(entry->Url); a_Capi_conn_abort_by_url(url); + /* Necessary when 'conn' is already done */ + Cache_entry_remove(NULL, url); entry = NULL; - if (OfferDownload && Cache_download_enabled(url)) { + if (OfferDownload && a_Cache_download_enabled(url)) { Cache_savelink_t *data = dNew(Cache_savelink_t, 1); data->bw = Client_bw; data->url = url; diff --git a/src/cache.h b/src/cache.h index ff286a0e..cdea361b 100644 --- a/src/cache.h +++ b/src/cache.h @@ -68,6 +68,7 @@ uint_t a_Cache_get_flags(const DilloUrl *url); uint_t a_Cache_get_flags_with_redirection(const DilloUrl *url); void a_Cache_process_dbuf(int Op, const char *buf, size_t buf_size, const DilloUrl *Url); +int a_Cache_download_enabled(const DilloUrl *url); void a_Cache_entry_inject(const DilloUrl *Url, Dstr *data_ds); void a_Cache_entry_remove_by_url(DilloUrl *url); void a_Cache_freeall(void); @@ -187,6 +187,8 @@ static void Capi_conn_resume(void) /* * Abort the connection for a given url, using its CCC. * (OpAbort 2,BCK removes the cache entry) + * TODO: when conn is already done, the cache entry isn't removed. + * This may be wrong and needs a revision. */ void a_Capi_conn_abort_by_url(const DilloUrl *url) { @@ -341,15 +343,11 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData) MSG_WARN("Cannot open \"%s\" for writing.\n", web->filename); } } - } else { - if (!dStrcasecmp(scheme, "https") || - !dStrcasecmp(scheme, "http") || - !dStrcasecmp(scheme, "ftp")) { - server = "downloads"; - cmd = Capi_dpi_build_cmd(web, server); - a_Capi_dpi_send_cmd(web->url, web->bw, cmd, server, 1); - dFree(cmd); - } + } else if (a_Cache_download_enabled(web->url)) { + server = "downloads"; + cmd = Capi_dpi_build_cmd(web, server); + a_Capi_dpi_send_cmd(web->url, web->bw, cmd, server, 1); + dFree(cmd); } } else if (Capi_url_uses_dpi(web->url, &server)) { |