This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
When creating a new file, the dialog box applies a check for an existing file by the name entered. This check is implemented at the wrong point in the code, and there are two symptoms that demonstrate this. The check is currently happening (apparently) before a default extension is applied, and it should check after. for these two examples, assume a default prefix of .php - meaning that if I enter "NewFile" in the name box, "NewFile.php" is created. Symptom #1. if there exists a folder by the name NewFile in the directory, an entry of "NewFile" would cause the dialog to warn that the file already exists, even though the file name would end up being "NewFile.php" Symptom #2. (Causes user-land code loss!) If NewFile.php already exists, and you type "NewFile.php" in the file name field, you *correctly* get the "existing file" warning. However, if you just enter "NewFile" -even though the final file name will be "NewFile.php"- you *DO NOT* get the benefit of this warning, and your existing file is overwritten.
(In reply to comment #0) > When creating a new file, the dialog box applies a check for an existing file > by the name entered. > > This check is implemented at the wrong point in the code, and there are two > symptoms that demonstrate this. The check is currently happening (apparently) > before a default extension is applied, and it should check after. > > for these two examples, assume a default prefix of .php - meaning that if I > enter "NewFile" in the name box, "NewFile.php" is created. > > > Symptom #1. > if there exists a folder by the name NewFile in the directory, an entry of > "NewFile" would cause the dialog to warn that the file already exists, even > though the file name would end up being "NewFile.php" reproducible - confirmed on Product Version: NetBeans IDE Dev (Build 100329-6f4b3c4a45a6) > Symptom #2. (Causes user-land code loss!) > If NewFile.php already exists, and you type "NewFile.php" in the file name > field, you *correctly* get the "existing file" warning. However, if you just > enter "NewFile" -even though the final file name will be "NewFile.php"- you *DO > NOT* get the benefit of this warning, and your existing file is overwritten. not reproducible on Ubuntu Java: 1.6.0_16; Java HotSpot(TM) 64-Bit Server VM 14.2-b01
reproducible with newest build on MAC. On Linux it creates a file called index.php_1 if index.php exists already. On MAC, existing file is really rewritten. steps to reproduce: 1. create whatever empty project 2. open new file wizard by invoking pop-up menu on source files folder 3. create new file index.php by writing index.php into dialog window test OK: warning appears and you can't continue 4. replace "index.php" with "index" and create file test OK on Ubuntu: created file is index.php_1 test OK on WIN Vista: test FAILS on MAC: original index.php is replaced by new EMPTY index.php the part reporting "folder being recognized as file" will be reported as another issue since it's not P2 but P3 Product Version: NetBeans IDE Dev (Build 100329-6f4b3c4a45a6)
(In reply to comment #1) > (In reply to comment #0) > > When creating a new file, the dialog box applies a check for an existing file > > by the name entered. > > > > This check is implemented at the wrong point in the code, and there are two > > symptoms that demonstrate this. The check is currently happening (apparently) > > before a default extension is applied, and it should check after. > > > > for these two examples, assume a default prefix of .php - meaning that if I > > enter "NewFile" in the name box, "NewFile.php" is created. > > > > > > Symptom #1. > > if there exists a folder by the name NewFile in the directory, an entry of > > "NewFile" would cause the dialog to warn that the file already exists, even > > though the file name would end up being "NewFile.php" > > reproducible - confirmed on > Product Version: NetBeans IDE Dev (Build 100329-6f4b3c4a45a6) this part has been submitted as bug 183045 > > Symptom #2. (Causes user-land code loss!) > > If NewFile.php already exists, and you type "NewFile.php" in the file name > > field, you *correctly* get the "existing file" warning. However, if you just > > enter "NewFile" -even though the final file name will be "NewFile.php"- you *DO > > NOT* get the benefit of this warning, and your existing file is overwritten. > not reproducible on Ubuntu > Java: 1.6.0_16; Java HotSpot(TM) 64-Bit Server VM 14.2-b01
(In reply to comment #2) > reproducible with newest build on MAC. On Linux it creates a file called > index.php_1 if index.php exists already. On MAC, existing file is really > rewritten. > > steps to reproduce: > 1. create whatever empty project > 2. open new file wizard by invoking pop-up menu on source files folder > 3. create new file index.php by writing index.php into dialog window > test OK: warning appears and you can't continue > 4. replace "index.php" with "index" and create file > test OK on Ubuntu: created file is index.php_1 > test OK on WIN Vista: > test FAILS on MAC: original index.php is replaced by new EMPTY index.php > > the part reporting "folder being recognized as file" will be reported as > another issue since it's not P2 but P3 > > Product Version: NetBeans IDE Dev (Build 100329-6f4b3c4a45a6) sorry, test FAILS on Vista
IMHO issue #141886 needs to be fixed in order to fix this issue.
(In reply to comment #5) > IMHO issue #141886 needs to be fixed in order to fix this issue. I mean _correctly_ fixed. Meanwhile, I will try to work around this issue.
I have a work around, I will push it tomorrow and also I will change priority to P4 to keep it as a reminder.
Work arounded, please verify. Lowering to P4 to keep this issue as a reminder. http://hg.netbeans.org/web-main/rev/3a6bcf959de3
Integrated into 'main-golden', will be available in build *201004020200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/3a6bcf959de3 User: Tomas Mysik <tmysik@netbeans.org> Log: #182958: New File dialog overwrites existing file if... For the correct fix, bug #141886 needs to be fixed.
workaround verified on Product Version: NetBeans IDE Dev (Build 2010-04-06_18-04-30 ) Java: 1.6.0_14-ea; Java HotSpot(TM) Client VM 14.0-b12 don't have MAC right now so reopen if you reproduce on MAC, please.
can confirm that workaround works on solaris 10 as well
Issue #141886 is fixed now.
Product Version: NetBeans IDE Dev (Build 100415-927c690b5b34)