diff options
author | Eric Wong <e@80x24.org> | 2022-11-28 05:32:29 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-11-28 23:39:00 +0000 |
commit | f707a4b4cf265bbef7bdf170d21289cb6ec9966c (patch) | |
tree | 2baa2467adae488e46d4007c82810fffa7667422 /lib/PublicInbox | |
parent | 9b285533321b533a5257fd071e4200723c37aa8b (diff) | |
download | public-inbox-f707a4b4cf265bbef7bdf170d21289cb6ec9966c.tar.gz |
Users may save notes or edits in there, and it's only an example, so there's no need to mindlessly clobber it.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/LeiMirror.pm | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index e284f55d..04e54955 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -181,13 +181,16 @@ sub _write_inbox_config { my $buf = delete($self->{'txt._/text/config/raw'}) // return; my $dst = $self->{cur_dst} // $self->{dst}; my $f = "$dst/inbox.config.example"; - open my $fh, '>', $f or die "open($f): $!"; - print $fh $buf or die "print: $!"; - chmod(0444 & ~umask, $fh) or die "chmod($f): $!"; my $mtime = delete $self->{'mtime._/text/config/raw'}; - $fh->flush or die "flush($f): $!"; - if (defined $mtime) { - utime($mtime, $mtime, $fh) or die "utime($f): $!"; + if (sysopen(my $fh, $f, O_CREAT|O_EXCL|O_WRONLY)) { + print $fh $buf or die "print: $!"; + chmod(0444 & ~umask, $fh) or die "chmod($f): $!"; + $fh->flush or die "flush($f): $!"; + if (defined $mtime) { + utime($mtime, $mtime, $fh) or die "utime($f): $!"; + } + } elsif (!$!{EEXIST}) { + die "open($f): $!"; } my $cfg = PublicInbox::Config->git_config_dump($f, $self->{lei}->{2}); my $ibx = $self->{ibx} = {}; |