emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug on file publish
@ 2008-10-25  0:09 Richard Riley
  2008-10-26  6:42 ` Carsten Dominik
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Riley @ 2008-10-25  0:09 UTC (permalink / raw)
  To: org-mode


If I modify a file and then publish it using "C-c C-e f" without saving
it I get an error of the form:

,----
| File error: "Opening directory", "no such file or directory",
| "/home/shamrock/webs/mydomain/.#index.org"
`----

I traced it through with edebug (how do you set a watch on a variable? I
couldnt get it through my thick skull from the manual).

Anyway, the error occurs in

org-publish-get-base-files-1

and is a result of a broken link :
,----
| lrwxrwxrwx 1 shamrock shamrock 54 2008-10-25 02:03 .#index.org -> shamrock@development.mydomain.net.21672:1224638771
| shamrock@development:~/webs/mydomain$ cat .#index.org 
| cat: .#index.org: No such file or directory
`----

The link is created somewhere in the publish process and is not properly
constructed if the file has not been saved prior to publish.

Someone more familiar with the process might know immediately where to
fix it, if not I will have a crack next week.


-- 
We've arranged a civilization in which most crucial elements profoundly depend on science and technology.  We have also arranged things so that almost no one understands science and technology.  This is a prescription for disaster.  We might get away with it for a while, but sooner or later this combustible mixture of ignorance and power is going to blow up in our faces.  ~Carl Sagan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug on file publish
  2008-10-25  0:09 Bug on file publish Richard Riley
@ 2008-10-26  6:42 ` Carsten Dominik
  2008-10-26 21:56   ` Sebastian Rose
  2008-10-26 22:10   ` Sebastian Rose
  0 siblings, 2 replies; 7+ messages in thread
From: Carsten Dominik @ 2008-10-26  6:42 UTC (permalink / raw)
  To: Richard Riley; +Cc: org-mode

Hi Richard,

Maybe this is some file locking mechanism?

I am quite sure that Org does not create this file explicitly.

Can you try to figure out exactly how things happen in org-publish-get- 
base-files-1, and which line exactly is causing the error to be  
triggered?

- Carsten

On Oct 25, 2008, at 2:09 AM, Richard Riley wrote:

>
> If I modify a file and then publish it using "C-c C-e f" without  
> saving
> it I get an error of the form:
>
> ,----
> | File error: "Opening directory", "no such file or directory",
> | "/home/shamrock/webs/mydomain/.#index.org"
> `----
>
> I traced it through with edebug (how do you set a watch on a  
> variable? I
> couldnt get it through my thick skull from the manual).
>
> Anyway, the error occurs in
>
> org-publish-get-base-files-1
>
> and is a result of a broken link :
> ,----
> | lrwxrwxrwx 1 shamrock shamrock 54 2008-10-25 02:03 .#index.org -> shamrock@development.mydomain.net.21672 
> :1224638771
> | shamrock@development:~/webs/mydomain$ cat .#index.org
> | cat: .#index.org: No such file or directory
> `----
>
> The link is created somewhere in the publish process and is not  
> properly
> constructed if the file has not been saved prior to publish.
>
> Someone more familiar with the process might know immediately where to
> fix it, if not I will have a crack next week.
>
>
> -- 
> We've arranged a civilization in which most crucial elements  
> profoundly depend on science and technology.  We have also arranged  
> things so that almost no one understands science and technology.   
> This is a prescription for disaster.  We might get away with it for  
> a while, but sooner or later this combustible mixture of ignorance  
> and power is going to blow up in our faces.  ~Carl Sagan
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug on file publish
  2008-10-26  6:42 ` Carsten Dominik
@ 2008-10-26 21:56   ` Sebastian Rose
  2008-10-26 22:10   ` Sebastian Rose
  1 sibling, 0 replies; 7+ messages in thread
From: Sebastian Rose @ 2008-10-26 21:56 UTC (permalink / raw)
  To: org-mode

Just thinking aloud:


"Opening directory", "no such file or directory",
 >> | "/home/shamrock/webs/mydomain/.#index.org"

is exactly what grep always gives me in such e case (I often use
`grep -lFr string dir').


sh> ls -l /home/sebastian/notes/.#index.org
lrwxrwxrwx 1 sebastian sebastian 31 26. Okt 22:27 
/home/sebastian/notes/.#index.org -> sebastian@orgon.4849:1225047914

That means .#index.org is a link pointing to a non existent file.
4849 is the process (cat /proc/4849/cmdline), that edits the file
/home/sebastian/notes/.index.org, so it indeed seems to be a locking
mechanism.



Problem seems to be, that the error occurs when ever trying to
access the file, which simply can not work, since it's a link
pointing nowhere.

org-publish-get-base-files-1 excludes files, whos names consist entirely
of dots:
	(not (string-match "^\\.+$" fnd))

Maybe exclude files like 'sebastian@orgon.4849:1225047914'
too - hm - a totaly legal filename though...

Or extend the file-test, so it doesn't simply test for names, but
additionally tests for

'is it a file OR (is it link that points to a real file)'




Carsten Dominik wrote:
> Hi Richard,
> 
> Maybe this is some file locking mechanism?
> 
> I am quite sure that Org does not create this file explicitly.
> 
> Can you try to figure out exactly how things happen in 
> org-publish-get-base-files-1, and which line exactly is causing the 
> error to be triggered?
> 
> - Carsten
> 
> On Oct 25, 2008, at 2:09 AM, Richard Riley wrote:
> 
>>
>> If I modify a file and then publish it using "C-c C-e f" without saving
>> it I get an error of the form:
>>
>> ,----
>> | File error: "Opening directory", "no such file or directory",
>> | "/home/shamrock/webs/mydomain/.#index.org"
>> `----
>>
>> I traced it through with edebug (how do you set a watch on a variable? I
>> couldnt get it through my thick skull from the manual).
>>
>> Anyway, the error occurs in
>>
>> org-publish-get-base-files-1
>>
>> and is a result of a broken link :
>> ,----
>> | lrwxrwxrwx 1 shamrock shamrock 54 2008-10-25 02:03 .#index.org -> 
>> shamrock@development.mydomain.net.21672:1224638771
>> | shamrock@development:~/webs/mydomain$ cat .#index.org
>> | cat: .#index.org: No such file or directory
>> `----
>>
>> The link is created somewhere in the publish process and is not properly
>> constructed if the file has not been saved prior to publish.
>>
>> Someone more familiar with the process might know immediately where to
>> fix it, if not I will have a crack next week.
>>
>>
>> -- 
>> We've arranged a civilization in which most crucial elements 
>> profoundly depend on science and technology.  We have also arranged 
>> things so that almost no one understands science and technology.  This 
>> is a prescription for disaster.  We might get away with it for a 
>> while, but sooner or later this combustible mixture of ignorance and 
>> power is going to blow up in our faces.  ~Carl Sagan
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Remember: use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> 
> 
> 
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug on file publish
  2008-10-26  6:42 ` Carsten Dominik
  2008-10-26 21:56   ` Sebastian Rose
@ 2008-10-26 22:10   ` Sebastian Rose
  2008-10-26 23:55     ` Sebastian Rose
  1 sibling, 1 reply; 7+ messages in thread
From: Sebastian Rose @ 2008-10-26 22:10 UTC (permalink / raw)
  To: org-mode, Carsten Dominik

Hi,

in org-publish-get-base-files-1


(car (file-attributes "~/notes/.#index.org"))

gives sebastian@orgon.4849:1225047914

!!!

So we have to test, if fd-p is the name of an existing file in
base-dir. That's it.

	    (if (and fd-p --HERE--  recurse
		     (not (string-match "^\\.+$" fnd))
		     (if skip-dir (not (string-match skip-dir fnd)) t))

Regards,

   Sebastian



Carsten Dominik wrote:
> Hi Richard,
> 
> Maybe this is some file locking mechanism?
> 
> I am quite sure that Org does not create this file explicitly.
> 
> Can you try to figure out exactly how things happen in 
> org-publish-get-base-files-1, and which line exactly is causing the 
> error to be triggered?
> 
> - Carsten
> 
> On Oct 25, 2008, at 2:09 AM, Richard Riley wrote:
> 
>>
>> If I modify a file and then publish it using "C-c C-e f" without saving
>> it I get an error of the form:
>>
>> ,----
>> | File error: "Opening directory", "no such file or directory",
>> | "/home/shamrock/webs/mydomain/.#index.org"
>> `----
>>
>> I traced it through with edebug (how do you set a watch on a variable? I
>> couldnt get it through my thick skull from the manual).
>>
>> Anyway, the error occurs in
>>
>> org-publish-get-base-files-1
>>
>> and is a result of a broken link :
>> ,----
>> | lrwxrwxrwx 1 shamrock shamrock 54 2008-10-25 02:03 .#index.org -> 
>> shamrock@development.mydomain.net.21672:1224638771
>> | shamrock@development:~/webs/mydomain$ cat .#index.org
>> | cat: .#index.org: No such file or directory
>> `----
>>
>> The link is created somewhere in the publish process and is not properly
>> constructed if the file has not been saved prior to publish.
>>
>> Someone more familiar with the process might know immediately where to
>> fix it, if not I will have a crack next week.
>>
>>
>> -- 
>> We've arranged a civilization in which most crucial elements 
>> profoundly depend on science and technology.  We have also arranged 
>> things so that almost no one understands science and technology.  This 
>> is a prescription for disaster.  We might get away with it for a 
>> while, but sooner or later this combustible mixture of ignorance and 
>> power is going to blow up in our faces.  ~Carl Sagan
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Remember: use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> 
> 
> 
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug on file publish
  2008-10-26 22:10   ` Sebastian Rose
@ 2008-10-26 23:55     ` Sebastian Rose
  2008-10-27  5:24       ` Carsten Dominik
  2008-10-27  7:22       ` Carsten Dominik
  0 siblings, 2 replies; 7+ messages in thread
From: Sebastian Rose @ 2008-10-26 23:55 UTC (permalink / raw)
  Cc: org-mode, Carsten Dominik

Hi,


I tried to use (file-locked-p f) in org-publish-base-files-1,
but I couldn't get it to work.

(file-locked-p "~/notes/index.org") ;; => t if "~/notes/.#index.org" exists.

.#index.org is only there, if I change the file without saving it. It's
removed, if I save the buffer.




A working quick fix:

Instead of
      (not (string-match "^\\.+$" fnd))
use
      (not (string-match "^\\.+" fnd))

in org-publish-base-files-1

Drawbacks:
- we can't export hidden files anymore.
   Or is that a feature?



It might be better to look for locked project files, or those still
opened in emacs, and ask the user to save those files before publishing
them. Unsaved changes in a buffer are not published before saving them
anyway. So a warning would be usefull anyway. A user might be surprised
if unsaved changes are not published, as unsaved changes are exported.




Anyway - here's the little patch:


diff --git a/lisp/org-publish.el b/lisp/org-publish.el
index 2af71d3..46fd055 100644
--- a/lisp/org-publish.el
+++ b/lisp/org-publish.el
@@ -430,7 +430,7 @@ matching the regexp SKIP-DIR when recursiing through 
BASE-DIR."
           (let ((fd-p (car (file-attributes f)))
                 (fnd (file-name-nondirectory f)))
             (if (and fd-p recurse
-                    (not (string-match "^\\.+$" fnd))
+                    (not (string-match "^\\.+" fnd))
                      (if skip-dir (not (string-match skip-dir fnd)) t))
                 (org-publish-get-base-files-1 f recurse match skip-file 
skip-dir)
               (unless (or fd-p ;; this is a directory

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Bug on file publish
  2008-10-26 23:55     ` Sebastian Rose
@ 2008-10-27  5:24       ` Carsten Dominik
  2008-10-27  7:22       ` Carsten Dominik
  1 sibling, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2008-10-27  5:24 UTC (permalink / raw)
  To: sebastian_rose; +Cc: org-mode

Hi Sebastian,

thanks for all this analysis.

On Oct 27, 2008, at 12:55 AM, Sebastian Rose wrote:

> Hi,
>
>
> I tried to use (file-locked-p f) in org-publish-base-files-1,
> but I couldn't get it to work.
>
> (file-locked-p "~/notes/index.org") ;; => t if "~/notes/.#index.org"  
> exists.
>
> .#index.org is only there, if I change the file without saving it.  
> It's
> removed, if I save the buffer.
>
>
>
>
> A working quick fix:
>
> Instead of
>     (not (string-match "^\\.+$" fnd))
> use
>     (not (string-match "^\\.+" fnd))
>
> in org-publish-base-files-1
>
> Drawbacks:
> - we can't export hidden files anymore.
>  Or is that a feature?


Very good question.  I don't think it would be good to exclude them  
always, at least as "attachments" they would make sense, for example  
for defining certain permissions in html directories which are, if I  
remember correctly, stored in dotfiles.

I see two solutions:

- exclude files starting with ".#"
- do more explicit checking by resolving the link and looking at the  
file pointed to.

The first one looks simple and perfectly effective to me.  Also it  
seems to me that, since these links seem to pop up as an indication  
that the file is being modified, they should *never* be published!  So  
we should exclude these for sure.

However, dead soft links could be a problem in general.  So we could  
also check for
(file-exists-p (file-truename file))

Should I add both?

- Carsten

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug on file publish
  2008-10-26 23:55     ` Sebastian Rose
  2008-10-27  5:24       ` Carsten Dominik
@ 2008-10-27  7:22       ` Carsten Dominik
  1 sibling, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2008-10-27  7:22 UTC (permalink / raw)
  To: sebastian_rose; +Cc: org-mode


[-- Attachment #1.1: Type: text/plain, Size: 2048 bytes --]

Hi Sebastian and Richard,

I just pushed what I think fixes this bug, please verify.

Thanks.

- Carsten

On Oct 27, 2008, at 12:55 AM, Sebastian Rose wrote:

> Hi,
>
>
> I tried to use (file-locked-p f) in org-publish-base-files-1,
> but I couldn't get it to work.
>
> (file-locked-p "~/notes/index.org") ;; => t if "~/notes/.#index.org"  
> exists.
>
> .#index.org is only there, if I change the file without saving it.  
> It's
> removed, if I save the buffer.
>
>
>
>
> A working quick fix:
>
> Instead of
>    (not (string-match "^\\.+$" fnd))
> use
>    (not (string-match "^\\.+" fnd))
>
> in org-publish-base-files-1
>
> Drawbacks:
> - we can't export hidden files anymore.
> Or is that a feature?
>
>
>
> It might be better to look for locked project files, or those still
> opened in emacs, and ask the user to save those files before  
> publishing
> them. Unsaved changes in a buffer are not published before saving them
> anyway. So a warning would be usefull anyway. A user might be  
> surprised
> if unsaved changes are not published, as unsaved changes are exported.
>
>
>
>
> Anyway - here's the little patch:
>
>
> diff --git a/lisp/org-publish.el b/lisp/org-publish.el
> index 2af71d3..46fd055 100644
> --- a/lisp/org-publish.el
> +++ b/lisp/org-publish.el
> @@ -430,7 +430,7 @@ matching the regexp SKIP-DIR when recursiing  
> through BASE-DIR."
>         (let ((fd-p (car (file-attributes f)))
>               (fnd (file-name-nondirectory f)))
>           (if (and fd-p recurse
> -                    (not (string-match "^\\.+$" fnd))
> +                    (not (string-match "^\\.+" fnd))
>                    (if skip-dir (not (string-match skip-dir fnd)) t))
>               (org-publish-get-base-files-1 f recurse match skip- 
> file skip-dir)
>             (unless (or fd-p ;; this is a directory
>
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[-- Attachment #1.2: Type: text/html, Size: 5321 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-10-27  7:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-25  0:09 Bug on file publish Richard Riley
2008-10-26  6:42 ` Carsten Dominik
2008-10-26 21:56   ` Sebastian Rose
2008-10-26 22:10   ` Sebastian Rose
2008-10-26 23:55     ` Sebastian Rose
2008-10-27  5:24       ` Carsten Dominik
2008-10-27  7:22       ` Carsten Dominik

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