* bug#8827: Problem in url-cache
@ 2011-06-08 23:35 Nick Dokos
2011-06-09 7:37 ` Eli Zaretskii
2011-07-06 7:49 ` Julien Danjou
0 siblings, 2 replies; 3+ messages in thread
From: Nick Dokos @ 2011-06-08 23:35 UTC (permalink / raw)
To: 8827; +Cc: Julien Danjou, nicholas.dokos
I was chasing down some problems I was having with Julien Danjou's
google-weather. The blow-by-blow description can be found in the
following threads on the emacs and orgmode mailing lists:
http://thread.gmane.org/gmane.emacs.help/81302
http://thread.gmane.org/gmane.emacs.orgmode/42565
This bug report (and possible patch) concern one aspect of this:
google-weather uses the url package to retrieve icons in GIF format (but
the problem may arise from any kind of binary data) from the server and
caches them locally for 12 hours by default. It does that by calling
url-store-in-cache:
(defun url-store-in-cache (&optional buff)
"Store buffer BUFF in the cache."
(with-current-buffer (get-buffer (or buff (current-buffer)))
(let ((fname (url-cache-create-filename (url-view-url t))))
(if (url-cache-prepare fname)
(let ((coding-system-for-write 'binary))
(write-region (point-min) (point-max) fname nil 5))))))
While the cache is valid, it then fetches the cached data by calling
url-cache-extract:
(defun url-cache-extract (fnam)
"Extract FNAM from the local disk cache."
(erase-buffer)
(insert-file-contents-literally fnam))
But it seems that in a multibyte context, what url-store-in-cache
stores and what url-cache-extract retrieves are not identical:
the former stores a sequence of bytes as they come from the network
and the latter may combine individual bytes into multibyte entities.
My workaround for this problem is
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
index 1615920..80d7702 100644
--- a/lisp/url/url-cache.el
+++ b/lisp/url/url-cache.el
@@ -192,6 +192,7 @@ Very fast if you have an `md5' primitive function, suitably fast otherwise."
(defun url-cache-extract (fnam)
"Extract FNAM from the local disk cache."
(erase-buffer)
+ (set-buffer-multibyte nil)
(insert-file-contents-literally fnam))
(defun url-cache-expired (url &optional expire-time)
--8<---------------cut here---------------end--------------->8---
It seems to work satisfactorily for google-weather. I don't know whether
it causes problems in other ways.
Thanks,
Nick
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#8827: Problem in url-cache
2011-06-08 23:35 bug#8827: Problem in url-cache Nick Dokos
@ 2011-06-09 7:37 ` Eli Zaretskii
2011-07-06 7:49 ` Julien Danjou
1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2011-06-09 7:37 UTC (permalink / raw)
To: nicholas.dokos; +Cc: julien, nicholas.dokos, 8827
> From: Nick Dokos <nicholas.dokos@hp.com>
> Date: Wed, 08 Jun 2011 19:35:45 -0400
> Cc: Julien Danjou <julien@danjou.info>, nicholas.dokos@hp.com
>
> (defun url-cache-extract (fnam)
> "Extract FNAM from the local disk cache."
> (erase-buffer)
> (insert-file-contents-literally fnam))
>
> But it seems that in a multibyte context, what url-store-in-cache
> stores and what url-cache-extract retrieves are not identical:
> the former stores a sequence of bytes as they come from the network
> and the latter may combine individual bytes into multibyte entities.
>
> My workaround for this problem is
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
> index 1615920..80d7702 100644
> --- a/lisp/url/url-cache.el
> +++ b/lisp/url/url-cache.el
> @@ -192,6 +192,7 @@ Very fast if you have an `md5' primitive function, suitably fast otherwise."
> (defun url-cache-extract (fnam)
> "Extract FNAM from the local disk cache."
> (erase-buffer)
> + (set-buffer-multibyte nil)
> (insert-file-contents-literally fnam))
That's not a workaround, that's exactly the fix for this bug.
Inserting binary data into a multibyte buffer does not leave the
binary data unaltered. The buffer must be unibyte.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#8827: Problem in url-cache
2011-06-08 23:35 bug#8827: Problem in url-cache Nick Dokos
2011-06-09 7:37 ` Eli Zaretskii
@ 2011-07-06 7:49 ` Julien Danjou
1 sibling, 0 replies; 3+ messages in thread
From: Julien Danjou @ 2011-07-06 7:49 UTC (permalink / raw)
To: nicholas.dokos; +Cc: control, 8827
[-- Attachment #1: Type: text/plain, Size: 113 bytes --]
close 8827
thanks
I've pushed your fix into the trunk.
--
Julien Danjou
❱ http://julien.danjou.info
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-07-06 7:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-08 23:35 bug#8827: Problem in url-cache Nick Dokos
2011-06-09 7:37 ` Eli Zaretskii
2011-07-06 7:49 ` Julien Danjou
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).