[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [BUG] bug in org-publish and a (wrong) patch
From: |
Nick Dokos |
Subject: |
[O] [BUG] bug in org-publish and a (wrong) patch |
Date: |
Thu, 07 Apr 2011 01:11:00 -0400 |
org-publish-cache-ctime-of-src tries (but does not always succeed) to
deal with symlinks: file-symlink-p returns the target as a string, but
if the target is relative to the symlink, that's not going to fly.
e.g. if c is a symlink like this
/a/b/c->../d/f
then (file-symlink-p "/a/b/c") -> "../d/f"
but if the current directory is any place other than /a/b, the target
will not be found, the file attributes are going to be nil and
the function will blow up.
Here is a patch born of about 5 mins of contemplation. It solved my
immediate problem but it is certainly wrong. It breaks absolute targets
(which I think are handled correctly by the original version). I'm not
even sure that it correctly handles *all* relative targets. It also
needs to treat the case of a non-existent symlink target (where
file-symlink-p returns t).
It might be safer also to check if the file attributes are
nil and deal with that, instead of blowing up.
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/org-publish.el b/lisp/org-publish.el
index e944eea..dd192d6 100644
--- a/lisp/org-publish.el
+++ b/lisp/org-publish.el
@@ -1150,7 +1150,7 @@ Returns value on success, else nil."
(defun org-publish-cache-ctime-of-src (filename)
"Get the FILENAME ctime as an integer."
(let ((src-attr (file-attributes (if (stringp (file-symlink-p filename))
- (file-symlink-p filename)
+ (concat (file-name-directory filename)
(file-symlink-p filename))
filename))))
(+
(lsh (car (nth 5 src-attr)) 16)
--8<---------------cut here---------------end--------------->8---
Nick
- [O] [BUG] bug in org-publish and a (wrong) patch,
Nick Dokos <=