#12380 closed defect (fixed)
[patch] fixed confirmation of overwriting existing file
Reported by: | kolesar | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 16.02 |
Component: | Core | Version: | |
Keywords: | Cc: |
Description
There was a comment in SaveActionBase.checkFileAndConfirmOverWrite
:
Confirm overwrite, except for OSX native file dialogs which already ask for confirmation (see #11362)
Tried it on Linux and Windows. Native file chooser asked me for overwrite and then JOSM asked again. It seems this issue did not only affect OSX. Removed condition Main.isPlatformOsx()
but I still got JOSM questions when I have chosen a file in a native save dialog. Why?
There was another call to confirmOverwrite()
: FileChooserManager.openFileChooser()
also asked for overwrite. Why twice?
First time openFileChooser called confirmOverwrite(), then returned AbstractFileChooser. Later checkFileAndConfirmOverWrite checked if FileFilter accepts file. When filename did not have aprropriate extension, filename was extended and checked again with confirmOverwrite(). Why was only one JOSM confirm dialog?
Because if FileChooser got full filename, then dialog was displayed by openFileChooser and if filename did not have extension, then checkFileAndConfirmOverWrite asked with new filename. If only one of the filenames existed, only one dialog was fired. (See related bug below.)
Commit [8248] fixed only second call of confirmOverwrite() and only for OSX. Linux and Windows was probably not tested. Native file dialogs of these operating systems (at least those I had access to: Xubuntu and Windows 7) behave the same way as OSX, so double dialog remained an issue.
Even on OSX only the half of the issue was solved, when user typed name without extension. If file was full path to an exisiting file, openFileChooser popped up a question. (Not tested because MacBook charger cable was recently damaged.)
Solved situation by moving condition of native file chooser to FileChooserManager, without platform check.
Also solved another bug. In a rare condition when user typed a name that did not have an apropriate extension for filter but a file with that name existed, one more confirmation dialog were fired. If the file with extension also existed, then JOSM asked twice. If native file chooser was used, one more confirmation was asked, totally three. Test it on any version between [8248] to current releases. For example create files named test
and test.osm
, then save osm layer as test
.
As I see we can't disable overwrite confirmation of native file chooser for the partial (but existing) filename. We could move confirmation logic later in workflow (from FileChooserManager to SaveActionBase) but other classes may rely on FileChooserManager only and if it does not confirms file overwrite then files would be overwritten without notice.
SaveActionBase therefore checks if partial filename already pointed to an existing file (= overwrite question was already answered) and does not ask again.
There is only one issue remained unsolved: when partial filename exists but extendes filename not. In this case native file dialog pops up confirmation and FileChooserManager does the same because it does not know yet that different filename will be used. I think it is a really rare condition. JOSM should ask once rather none or 2-3 times. This patch does this way.
Attachments (1)
Change History (9)
follow-ups: 2 4 comment:1 by , 9 years ago
follow-up: 5 comment:2 by , 9 years ago
Replying to simon04:
On Linux the native file chooser does not show the overwrite confirmation when the filename is entered in the dialog w/o the extension. For instance, having an existing file
foobar.osm
, and saving a layer by typingfoobar
into the native file dialog, no confirmation is shown …
I have got the same results on Windows, too. That's why I have removed checking platform.
JOSM [8248] disabled JOSM's second stage confirmation on Mac while native file chooser is in the first stage. Therefore I think JOSM on Mac currently does not ask for overwrite if you type file name without .osm extension.
(I have soldered charger cable for MacBook, it works again but still unable to test JOSM because Java 7 only runs on Macs with 64-bit processor. Is somebody here with a Mac?)
First stage is typed/choosen filename coming from dialog, related to FileChooserManager
. Second stage is when missing extension was applied in SaveActionBase
.
File chooser is fired by FileChooserManager
. When native file choosed is used, confirmation should be skipped here, in the first stage. Not in second stage at SaveActionBase
as [8248] did.
comment:3 by , 9 years ago
Summary: | [patch] fixed confirmation of overwriting exisiting file → [patch] fixed confirmation of overwriting existing file |
---|
comment:4 by , 9 years ago
Replying to simon04:
Tried it on Linux and Windows. Native file chooser asked me for overwrite and then JOSM asked again.
On Linux the native file chooser does not show the overwrite confirmation when the filename is entered in the dialog w/o the extension. For instance, having an existing file
foobar.osm
, and saving a layer by typingfoobar
into the native file dialog, no confirmation is shown …
Have you applied the patch and tested?
On my system, the patch handles this correctly. When typing foobar
into the native file dialog, there is a JOSM window asking for confirmation.
comment:5 by , 9 years ago
The patch doesn't apply anymore, could you please update?
Replying to kolesar:
Replying to simon04:
On Linux the native file chooser does not show the overwrite confirmation when the filename is entered in the dialog w/o the extension. For instance, having an existing file
foobar.osm
, and saving a layer by typingfoobar
into the native file dialog, no confirmation is shown …
I have got the same results on Windows, too. That's why I have removed checking platform.
JOSM [8248] disabled JOSM's second stage confirmation on Mac while native file chooser is in the first stage. Therefore I think JOSM on Mac currently does not ask for overwrite if you type file name without .osm extension.
Correct, I've tested this on OS X 10.9.
(I have soldered charger cable for MacBook, it works again but still unable to test JOSM because Java 7 only runs on Macs with 64-bit processor. Is somebody here with a Mac?)
see #10455 :)
by , 9 years ago
Attachment: | ConfirmFileOverwrite.patch added |
---|
comment:8 by , 9 years ago
Milestone: | → 16.02 |
---|
On Linux the native file chooser does not show the overwrite confirmation when the filename is entered in the dialog w/o the extension. For instance, having an existing file
foobar.osm
, and saving a layer by typingfoobar
into the native file dialog, no confirmation is shown …