2

I am using Netbeans 7.0.1 on a Linux system.

I have a file

module/test.php

and another one

application/module/test.php

Both test.php files are hardlinks of each other.

When I change application/module/test.php in Netbeans the module/test.php is not updated. But it should.

I think Netbeans deletes the test.php and creates a new one?

I believe in Netbeans 6 this did not happen.

How can I fix this? Is there any hidden option to get the old behavior?

1
  • 1
    Probably to get atomic saves.
    – Daniel Beck
    Oct 31, 2011 at 12:48

2 Answers 2

1
+50

The proper way for a text editor to update (save) a file is to create a new file in the same directory with a temporary name, write new contents there and then delete old file and rename the new one to its real name.

Rationale: If you're rewriting a file in place, any catastrophic failure (power loss, bad sector on disk, etc.) may leave this file corrupted or only partly written. Therefore any sane editor does not do in-place writes. I'm rather amazed that NetBeans did that in older versions.

Of course, this delete/rename method is not aware of your hard link, and searching a whole disk for other hard links to a file is not an option, so no editor does this.

I don't think you can get an old behavior, and even if you could, this is a pretty bad idea. If you cannot switch to soft links (which are not affected by this issue), I suppose you'll have to look for some other way to do what you're doing.

1
  • So I guess I will try to switch to soft-links.
    – Alex
    Nov 7, 2011 at 20:27
1

As far as I know, Netbeans cannot be set to do a "one-stage" save, which is what you are asking for. What it does instead is a "two-stage" save.

An editor that can do that is jEdit, if that helps.
Here is what it says in the Saving Files section of the jEdit manual :

Two-Stage Save

To prevent data loss in the unlikely case that jEdit should crash in the middle of saving a file, files are first saved to a temporary file named #filename#save#. If this operation is successful, the original file is replaced with the temporary file.

However, in some situations, this behavior is undesirable. For example, on Unix this creates a new i-node so while jEdit retains file permissions, the owner and group of the file are reset, and if it is a hard link the link is broken. The “two-stage save” feature can be disabled in the General pane of the Utilities>Global Options dialog box; see the section called “The General Pane”.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .