Opened on 11/18/2014 at 02:41:59 PM

Last modified on 07/02/2015 at 04:52:03 PM

#1582 new change

DefaultFileSystem should implement atomic write operations

Reported by: trev Assignee: Mailkov
Priority: P3 Milestone:
Module: Libadblockplus Keywords:
Cc: fhd, eric@adblockplus.org, mapx Blocked By:
Blocking: Platform: Unknown
Ready: yes Confidential: no
Tester: Verified working: no
Review URL(s):

Description (last modified by trev)

Background

Currently, DefaultFileSystem::Write() uses the trivial approach to write files. There are no guarantees that the file will be written completely, so if the program crashes while writing the file will be corrupted. Also, a hard reboot while the file is still in disk cache can lead to data corruption.

What to change

Make sure that the file is either written completely or stays unchanged. This can be done by using the approach currently implemented in Firefox:

  • Open temporary file. We simply add suffix .tmp to the file name, this ensures that the temp file is on the volume as the final file and that we don't create tons of temp files if we cannot clean up for some reason.
  • Write data to temporary file.
  • Flush data to disk.
  • Close temporary file.
  • Rename temporary file to have its final file name (replace existing file if necessary).
  • If any one of these steps causes an error - remove temporary file.

Attachments (0)

Change History (5)

comment:1 Changed on 11/18/2014 at 02:42:43 PM by trev

  • Description modified (diff)

comment:2 Changed on 11/18/2014 at 05:47:50 PM by mapx

  • Cc mapx added

comment:3 Changed on 06/21/2015 at 04:43:23 PM by Mailkov

I'd like to work on this ...

Please, can you assign it to me?

comment:4 Changed on 06/29/2015 at 06:26:32 PM by sergz

  • Owner set to Mailkov

comment:5 Changed on 07/02/2015 at 04:52:03 PM by Mailkov

Add Comment

Modify Ticket

Change Properties
Action
as new .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from Mailkov.
Next status will be 'reviewing'.
 
Note: See TracTickets for help on using tickets.