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.

Bug 182958 - New File dialog overwrites existing file if...
Summary: New File dialog overwrites existing file if...
Status: VERIFIED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: Macintosh (x86) Mac OS X
: P3 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on: 141886
Blocks:
  Show dependency tree
 
Reported: 2010-03-26 19:14 UTC by ctrahey
Modified: 2010-04-15 12:03 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ctrahey 2010-03-26 19:14:19 UTC
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.
Comment 1 Filip Zamboj 2010-03-29 09:11:34 UTC
(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
Comment 2 Filip Zamboj 2010-03-29 09:44:51 UTC
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)
Comment 3 Filip Zamboj 2010-03-29 09:52:08 UTC
(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
Comment 4 Filip Zamboj 2010-03-29 09:53:02 UTC
(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
Comment 5 Tomas Mysik 2010-03-31 15:41:38 UTC
IMHO issue #141886 needs to be fixed in order to fix this issue.
Comment 6 Tomas Mysik 2010-03-31 15:42:33 UTC
(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.
Comment 7 Tomas Mysik 2010-03-31 15:58:02 UTC
I have a work around, I will push it tomorrow and also I will change priority to P4 to keep it as a reminder.
Comment 8 Tomas Mysik 2010-04-01 08:40:47 UTC
Work arounded, please verify. Lowering to P4 to keep this issue as a reminder.
http://hg.netbeans.org/web-main/rev/3a6bcf959de3
Comment 9 Quality Engineering 2010-04-02 04:51:59 UTC
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.
Comment 10 Filip Zamboj 2010-04-06 15:37:30 UTC
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.
Comment 11 Filip Zamboj 2010-04-07 14:04:22 UTC
can confirm that workaround works on solaris 10 as well
Comment 12 Tomas Mysik 2010-04-13 17:20:27 UTC
Issue #141886 is fixed now.
Comment 13 Filip Zamboj 2010-04-15 12:03:27 UTC
Product Version: NetBeans IDE Dev (Build 100415-927c690b5b34)