mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-25 07:49:38 +03:00
llcache: Avoid putting local content in the disc cache.
This commit is contained in:
parent
26d7a167ae
commit
ad27ed6926
@ -1519,6 +1519,34 @@ format_error:
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a scheme is persistable.
|
||||
*
|
||||
* \param url URL to check.
|
||||
* \return true iff url has a persistable scheme.
|
||||
*/
|
||||
static inline bool llcache__scheme_is_persistable(const nsurl *url)
|
||||
{
|
||||
lwc_string *scheme = nsurl_get_component(url, NSURL_SCHEME);
|
||||
bool persistable = false;
|
||||
bool match;
|
||||
|
||||
/* nsurl ensures lower case schemes, and corestrings are lower
|
||||
* case, so it's safe to use case-sensitive comparison. */
|
||||
if ((lwc_string_isequal(scheme, corestring_lwc_http,
|
||||
&match) == lwc_error_ok &&
|
||||
(match == true)) ||
|
||||
(lwc_string_isequal(scheme, corestring_lwc_https,
|
||||
&match) == lwc_error_ok &&
|
||||
(match == true))) {
|
||||
persistable = true;
|
||||
}
|
||||
|
||||
lwc_string_unref(scheme);
|
||||
|
||||
return persistable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a scheme is cachable.
|
||||
*
|
||||
@ -1578,6 +1606,12 @@ llcache_object_fetch_persistent(llcache_object *object,
|
||||
nsurl *referer_clone = NULL;
|
||||
llcache_post_data *post_clone = NULL;
|
||||
|
||||
if (!llcache__scheme_is_persistable(object->url)) {
|
||||
/* Don't bother looking up non-http(s) stuff; we don't
|
||||
* persist it. */
|
||||
return NSERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
object->cache.req_time = time(NULL);
|
||||
object->cache.fin_time = object->cache.req_time;
|
||||
|
||||
@ -2494,6 +2528,11 @@ build_candidate_list(struct llcache_object ***lst_out, int *lst_len_out)
|
||||
for (object = llcache->cached_objects; object != NULL; object = next) {
|
||||
next = object->next;
|
||||
|
||||
/* Only consider http(s) for the disc cache. */
|
||||
if (!llcache__scheme_is_persistable(object->url)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
remaining_lifetime = llcache_object_rfc2616_remaining_lifetime(
|
||||
&object->cache);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user