Closed
Bug 1171992
Opened 11 years ago
Closed 11 years ago
renaming issue with OS.File - rename to name of file that already exists and file disappears
Categories
(Toolkit Graveyard :: OS.File, defect)
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: noitidart, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0
Build ID: 20150601171003
Steps to reproduce:
1. Create on desktop a file named a.txt
2. Create on desktop a file named b.txt
3. Run this code, it renames a.txt to c.txt and you can look at your desktop for evidence
```
OS.File.move(OS.Path.join(OS.Constants.Path.desktopDir, 'a.txt'), OS.Path.join(OS.Constants.Path.desktopDir, 'c.txt')).then(x=>console.log('success:',x),y=>console.warn('rejected:',y)).catch(z=>console.error('caught:',z));
```
4. Now lets rename c.txt to b.txt, this should give us an error as b.txt already exists
```
OS.File.move(OS.Path.join(OS.Constants.Path.desktopDir, 'c.txt'), OS.Path.join(OS.Constants.Path.desktopDir, 'b.txt')).then(x=>console.log('success:',x),y=>console.warn('rejected:',y)).catch(z=>console.error('caught:',z));
```
Actual results:
We see no error is thrown, and c.txt just disappears, tested on Win8.1
Expected results:
An error saying cannot move as another file with the same name already exists
Component: Untriaged → OS.File
OS: Unspecified → Windows 8.1
Product: Firefox → Toolkit
Hardware: Unspecified → x86_64
Hi Yoric is this the right way to rename things with os.file? This is a bug isnt it?
Flags: needinfo?(dteller)
Comment 2•11 years ago
|
||
According to my tests (on MacOS X), this erases b.txt and replaces it with c.txt, as per documentation. If you wish to make sure that you are not overwriting, you need option `noOverwrite`.
Flags: needinfo?(dteller)
(In reply to David Rajchenbach-Teller [:Yoric] (use "needinfo") from comment #2)
> According to my tests (on MacOS X), this erases b.txt and replaces it with
> c.txt, as per documentation. If you wish to make sure that you are not
> overwriting, you need option `noOverwrite`.
Ahhhh I missed that I gotta read better, thanks!!
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → INVALID
Updated•3 years ago
|
Product: Toolkit → Toolkit Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•