emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: nicholas.dokos@hp.com
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG] bug in org-publish and a (wrong) patch
Date: Fri, 8 Apr 2011 12:22:15 +0200	[thread overview]
Message-ID: <A74BA9A8-65A5-4DA9-8FB7-4D3EA83568FC@gmail.com> (raw)
In-Reply-To: <8052.1302153060@alphaville.dokosmarshall.org>

Hi Nick,

I have not looked closely, but maybe you can use


(expand-file-name  .... (file-name-directory filename))

to fix this patch?  Not sure, I have not spent any time on it.

- Carsten

On Apr 7, 2011, at 7:11 AM, Nick Dokos wrote:

> 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
> 

- Carsten

  parent reply	other threads:[~2011-04-08 10:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-07  5:11 [BUG] bug in org-publish and a (wrong) patch Nick Dokos
2011-04-07  5:37 ` Nick Dokos
2011-04-08 10:22 ` Carsten Dominik [this message]
2011-04-08 16:58   ` Nick Dokos
2011-06-26 18:10     ` David Maus
2011-06-27  4:12       ` Nick Dokos
2011-06-27  4:24         ` David Maus

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=A74BA9A8-65A5-4DA9-8FB7-4D3EA83568FC@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=nicholas.dokos@hp.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).