﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
12380	[patch] fixed confirmation of overwriting existing file	kolesar	team	"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."	defect	closed	normal	16.02	Core		fixed		
