summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
cfb8d16)
We can't have files with permissions inconsistent with what's
in git objects.
sub dbh_new {
my ($f, $writable) = @_;
sub dbh_new {
my ($f, $writable) = @_;
+ if ($writable && !-f $f) { # SQLite defaults mode to 0644, we want 0666
+ open my $fh, '+>>', $f or die "failed to open $f: $!";
+ }
my $dbh = DBI->connect("dbi:SQLite:dbname=$f",'','', {
AutoCommit => 1,
RaiseError => 1,
my $dbh = DBI->connect("dbi:SQLite:dbname=$f",'','', {
AutoCommit => 1,
RaiseError => 1,
sub dbh_new {
my ($self) = @_;
my $ro = ref($self) eq 'PublicInbox::Over';
sub dbh_new {
my ($self) = @_;
my $ro = ref($self) eq 'PublicInbox::Over';
- my $dbh = DBI->connect("dbi:SQLite:dbname=$self->{filename}",'','', {
+ my $f = $self->{filename};
+ if (!$ro && !-f $f) { # SQLite defaults mode to 0644, we want 0666
+ open my $fh, '+>>', $f or die "failed to open $f: $!";
+ }
+ my $dbh = DBI->connect("dbi:SQLite:dbname=$f",'','', {
AutoCommit => 1,
RaiseError => 1,
PrintError => 0,
AutoCommit => 1,
RaiseError => 1,
PrintError => 0,
}
$v2ibx = PublicInbox::InboxWritable->new($v2ibx);
}
$v2ibx = PublicInbox::InboxWritable->new($v2ibx);
my $xpfx = "$dir/xap" . PublicInbox::Search::SCHEMA_VERSION;
my $self = {
my $xpfx = "$dir/xap" . PublicInbox::Search::SCHEMA_VERSION;
my $self = {
# mimics Import::add and wraps it for v2
sub add {
my ($self, $mime, $check_cb) = @_;
# mimics Import::add and wraps it for v2
sub add {
my ($self, $mime, $check_cb) = @_;
+ $self->{-inbox}->with_umask(sub {
+ _add($self, $mime, $check_cb)
+ });
+}
+
+sub _add {
+ my ($self, $mime, $check_cb) = @_;
# spam check:
if ($check_cb) {
# spam check:
if ($check_cb) {
sub remove {
my ($self, $mime, $cmt_msg) = @_;
sub remove {
my ($self, $mime, $cmt_msg) = @_;
- remove_internal($self, $mime, $cmt_msg);
+ $self->{-inbox}->with_umask(sub {
+ remove_internal($self, $mime, $cmt_msg);
+ });
}
sub purge {
my ($self, $mime) = @_;
}
sub purge {
my ($self, $mime) = @_;
- my $purges = remove_internal($self, $mime, undef, {});
+ my $purges = $self->{-inbox}->with_umask(sub {
+ remove_internal($self, $mime, undef, {});
+ });
$self->idx_init if @$purges; # ->done is called on purges
for my $i (0..$#$purges) {
defined(my $cmt = $purges->[$i]) or next;
$self->idx_init if @$purges; # ->done is called on purges
for my $i (0..$#$purges) {
defined(my $cmt = $purges->[$i]) or next;
ok($@, "exception raised on non-existent DB");
my $rw = PublicInbox::SearchIdx->new($git_dir, 1);
ok($@, "exception raised on non-existent DB");
my $rw = PublicInbox::SearchIdx->new($git_dir, 1);
-$rw->_xdb_acquire;
-$rw->_xdb_release;
+$ibx->with_umask(sub {
+ $rw->_xdb_acquire;
+ $rw->_xdb_release;
+});
$rw = undef;
my $ro = PublicInbox::Search->new($git_dir);
my $rw_commit = sub {
$rw = undef;
my $ro = PublicInbox::Search->new($git_dir);
my $rw_commit = sub {
umask, 'umask => existing umask');
}
umask, 'umask => existing umask');
}
my $root = Email::MIME->create(
header_str => [
Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
my $root = Email::MIME->create(
header_str => [
Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
is($root_id, int($root_id), "root_id is an integer: $root_id");
$last_id = $rw->add_message($last);
is($last_id, int($last_id), "last_id is an integer: $last_id");
is($root_id, int($root_id), "root_id is an integer: $root_id");
$last_id = $rw->add_message($last);
is($last_id, int($last_id), "last_id is an integer: $last_id");
sub filter_mids {
my ($msgs) = @_;
sub filter_mids {
my ($msgs) = @_;
$rw_commit->();
my $rmid = '<ghost-message@s>';
my $reply_to_ghost = Email::MIME->create(
$rw_commit->();
my $rmid = '<ghost-message@s>';
my $reply_to_ghost = Email::MIME->create(
}
isnt($msgs->[0]->{num}, $msgs->[1]->{num}, "num do not match");
ok($_->{num} > 0, 'positive art num') foreach @$msgs
}
isnt($msgs->[0]->{num}, $msgs->[1]->{num}, "num do not match");
ok($_->{num} > 0, 'positive art num') foreach @$msgs
# search thread on ghost
{
# search thread on ghost
{
$rw_commit->();
$ro->reopen;
my $long_mid = 'last' . ('x' x 60). '@s';
$rw_commit->();
$ro->reopen;
my $long_mid = 'last' . ('x' x 60). '@s';
my @exp = sort($long_reply_mid, 'root@s', 'last@s', $long_mid);
@res = filter_mids($t);
is_deeply(\@res, \@exp, "get_thread works");
my @exp = sort($long_reply_mid, 'root@s', 'last@s', $long_mid);
@res = filter_mids($t);
is_deeply(\@res, \@exp, "get_thread works");
$rw_commit->();
$rw->add_message(Email::MIME->create(
header_str => [
$rw_commit->();
$rw->add_message(Email::MIME->create(
header_str => [
is(scalar(@$res), 1, "got a match for quoted text");
is($res->[0]->mid, 'quote@a',
"quoted result returned if nothing else");
is(scalar(@$res), 1, "got a match for quoted text");
is($res->[0]->mid, 'quote@a',
"quoted result returned if nothing else");
my $s = 'foo://'. ('Circle' x 15).'/foo';
my $doc_id = $rw->add_message(Email::MIME->create(
header => [ Subject => $s ],
my $s = 'foo://'. ('Circle' x 15).'/foo';
my $doc_id = $rw->add_message(Email::MIME->create(
header => [ Subject => $s ],
my $smsg = $rw->query('m:circle@a', {limit=>1})->[0];
is($smsg->references, '', "no references created");
is($s, $smsg->subject, 'long subject not rewritten');
my $smsg = $rw->query('m:circle@a', {limit=>1})->[0];
is($smsg->references, '', "no references created");
is($s, $smsg->subject, 'long subject not rewritten');
my $str = eval {
my $mbox = 't/utf8.mbox';
open(my $fh, '<', $mbox) or die "failed to open mbox: $mbox\n";
my $str = eval {
my $mbox = 't/utf8.mbox';
open(my $fh, '<', $mbox) or die "failed to open mbox: $mbox\n";
ok($doc_id > 0, 'message indexed doc_id with UTF-8');
my $msg = $rw->query('m:testmessage@example.com', {limit => 1})->[0];
is($mime->header('Subject'), $msg->subject, 'UTF-8 subject preserved');
ok($doc_id > 0, 'message indexed doc_id with UTF-8');
my $msg = $rw->query('m:testmessage@example.com', {limit => 1})->[0];
is($mime->header('Subject'), $msg->subject, 'UTF-8 subject preserved');
{
my $msgs = $ro->query('d:19931002..20101002');
{
my $msgs = $ro->query('d:19931002..20101002');
my $part1 = Email::MIME->create(
attributes => {
content_type => 'text/plain',
my $part1 = Email::MIME->create(
attributes => {
content_type => 'text/plain',
$rw->unindex_blob($amsg);
$rw->commit_txn_lazy;
is($ro->lookup_article($art->{num}), undef, 'gone from OVER DB');
$rw->unindex_blob($amsg);
$rw->commit_txn_lazy;
is($ro->lookup_article($art->{num}), undef, 'gone from OVER DB');
+});
+
+foreach my $f ("$git_dir/public-inbox/msgmap.sqlite3",
+ glob("$git_dir/public-inbox/xapian*/"),
+ glob("$git_dir/public-inbox/xapian*/*")) {
+ my @st = stat($f);
+ my ($bn) = (split(m!/!, $f))[-1];
+ is($st[2] & 07777, -f _ ? 0660 : 0770,
+ "sharedRepository respected for $bn");
};
is($im->{partitions}, 1, 'one partition when forced');
ok($im->add($mime), 'ordinary message added');
};
is($im->{partitions}, 1, 'one partition when forced');
ok($im->add($mime), 'ordinary message added');
+foreach my $f ("$mainrepo/msgmap.sqlite3",
+ glob("$mainrepo/xap*/*"),
+ glob("$mainrepo/xap*/*/*")) {
+ my @st = stat($f);
+ my ($bn) = (split(m!/!, $f))[-1];
+ is($st[2] & 07777, -f _ ? 0660 : 0770,
+ "default sharedRepository respected for $bn");
+}
+
my $git0;
if ('ensure git configs are correct') {
my $git0;
if ('ensure git configs are correct') {