all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Julien Danjou <julien@danjou.info>
To: emacs-devel@gnu.org
Cc: Julien Danjou <julien@danjou.info>
Subject: [PATCH 1/5] url-cache.el (url-cache-expired): Handle any type of cached object
Date: Wed, 15 Sep 2010 10:51:24 +0200	[thread overview]
Message-ID: <1284540688-7912-2-git-send-email-julien@danjou.info> (raw)
In-Reply-To: <1284540688-7912-1-git-send-email-julien@danjou.info>

Signed-off-by: Julien Danjou <julien@danjou.info>
---
 lisp/url/ChangeLog    |    1 +
 lisp/url/url-cache.el |   27 ++++++++++++---------------
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 7726f6c..a5e5c26 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,6 +1,7 @@
 2010-09-14  Julien Danjou  <julien@danjou.info>
 
 	* url-cache (url-store-in-cache): Make `buff' argument really optional.
+	(url-cache-expired): Handle any type of cached object.
 
 2010-09-14  Glenn Morris  <rgm@gnu.org>
 
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
index 3a6f00d..015a1ff 100644
--- a/lisp/url/url-cache.el
+++ b/lisp/url/url-cache.el
@@ -180,21 +180,18 @@ Very fast if you have an `md5' primitive function, suitably fast otherwise."
   (insert-file-contents-literally fnam))
 
 ;;;###autoload
-(defun url-cache-expired (url mod)
-  "Return t if a cached file has expired."
-  (let* ((urlobj (if (vectorp url) url (url-generic-parse-url url)))
-	 (type (url-type urlobj)))
-    (cond
-     (url-standalone-mode
-      (not (file-exists-p (url-cache-create-filename url))))
-     ((string= type "http")
-      t)
-     ((member type '("file" "ftp"))
-      (if (or (equal mod '(0 0)) (not mod))
-	  t
-	(or (> (nth 0 mod) (nth 0 (current-time)))
-	    (> (nth 1 mod) (nth 1 (current-time))))))
-     (t nil))))
+(defun url-cache-expired (url expire-time)
+  "Return t if a cached URL is more than EXPIRE-TIME old."
+    (cond (url-standalone-mode
+           (not (file-exists-p (url-cache-create-filename url))))
+          (t (let ((cache-time (url-is-cached url)))
+               (if cache-time
+                   (time-less-p
+                    (time-add
+                     (url-is-cached url)
+                     (seconds-to-time expire-time))
+                    (current-time))
+                 t)))))
 
 (provide 'url-cache)
 
-- 
1.7.1




  reply	other threads:[~2010-09-15  8:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-15  8:51 Enhance url-cache Julien Danjou
2010-09-15  8:51 ` Julien Danjou [this message]
2010-09-15  8:51 ` [PATCH 2/5] url-cache.el: (url-fetch-from-cache): Add new function Julien Danjou
2010-09-19 18:50   ` Glenn Morris
2010-09-15  8:51 ` [PATCH 3/5] url-cache.el: (url-is-cached): Enhance docstring Julien Danjou
2010-09-18 20:44   ` Glenn Morris
2010-09-15  8:51 ` [PATCH 4/5] url-vars.el: Remove useless variable `url-cache-expired' Julien Danjou
2010-09-18 20:50   ` Glenn Morris
2010-09-15  8:51 ` [PATCH 5/5] url-cache: add url-cache-expire-time Julien Danjou
2010-09-22 16:29 ` Enhance url-cache Julien Danjou
2010-09-22 17:09   ` Glenn Morris
2010-09-23  9:46     ` [PATCH] Fix URL documentation Julien Danjou
2010-09-24  2:38       ` Glenn Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1284540688-7912-2-git-send-email-julien@danjou.info \
    --to=julien@danjou.info \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.