improve flock usage

Signed-off-by: Mattias Andrée <maandree@operamail.com>
more pervasive use of backups

Signed-off-by: Mattias Andrée <maandree@operamail.com>
let the lock be shared while downloading and promote it to exclusive right before saving

Signed-off-by: Mattias Andrée <maandree@operamail.com>
don't flock whilst downloading

Signed-off-by: Mattias Andrée <maandree@operamail.com>