Opened 12 years ago

Closed 11 years ago

#7406 closed defect (fixed)

When there is an error during saving, original file is lost.

Reported by: anonymous Owned by: team
Priority: normal Milestone:
Component: Core Version: tested
Keywords: save file java7 Cc:


Josm semms to only save over the file when saving (opening a new FileOutputStream to the file).

The right thing to do would be create a new temporary file and move the temporary file AFTER successfully writing the data over to the position of the old file (File.renameTo(..))

Just a few minutes for a core developer, but could save hours of work ;-)

Attachments (0)

Change History (4)

comment:1 by Don-vip, 11 years ago

Keywords: java7 added
Priority: criticalnormal

Temporary files are already used when writing .osm files and preferences files.

However, the code could be improved as we have several "copy" implementations (at least Preferences.copyFile() and OsmExporter.copy that could be simply replaced to Files.copy when we will switch to Java 7.

comment:2 by Don-vip, 11 years ago

In 5874/josm:

see #8570, #7406 - I/O refactorization:

  • Move different file copy functions to Utils.copyFile (to be replaced later by Files.copy when switching to Java 7)
  • Replace all Utils.close(XXX) by Utils.close(Closeable) -> impacted plugins: commandline, mirrored_download, opendata, piclayer
  • Add new Utils.close(ZipFile)
  • Use of Utils.close almost everywhere
  • Javadoc fixes

comment:3 by aceman, 11 years ago

Is this still open?

comment:4 by Don-vip, 11 years ago

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.