Modify

Opened 16 months ago

Last modified 2 months ago

#7406 new defect

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

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

Description

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 (2)

comment:1 Changed 4 months ago by Don-vip

  • Keywords java7 added
  • Priority changed from critical to normal

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 Changed 2 months ago by Don-vip

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team. Next status will be 'new'.
Next status will be 'needinfo'.The owner will change to anonymous
as duplicate The resolution will be set to duplicate. Next status will be 'closed'.The specified ticket will be cross-referenced with this ticket
The owner will be changed from team to anonymous. Next status will be 'assigned'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.