Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
1  
Probably to get atomic saves. –  Daniel Beck Oct 31 '11 at 12:48
add comment

2 Answers

up vote 1 down vote accepted
+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.

share|improve this answer
    
So I guess I will try to switch to soft-links. –  Alex Nov 7 '11 at 20:27
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.