realpath(3) originally required a non-NULL 2nd argument. POSIX
extended it to allow NULL, but some old BSD versions still have the
as-first-introduced-in-4.4BSD implementation that does not accept the
2nd argument being NULL.
Define bup_realpath, which collapses to just system realpath for most
systems, and on systems known to have historic realpath, use a buffer,
and strdup the results, to match the POSIX-with-NULL semantics.
This should fix NetBSD and OpenBSD, and realpath isn't used on
FreeBSD. This does not attempt to address Solaris.
Signed-off-by: Greg Troxel <gdt@lexort.com> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: adjust commit message]
[rlb@defaultvalue.org: change #define to BUP_HAVE_POSIX_REALPATH]
[rlb@defaultvalue.org: add OpenBSD version guard clause]
[rlb@defaultvalue.org: nest NetBSD checks so Prereq doesn't crash elsewhere]
[rlb@defaultvalue.org: reformat bup_realpath a bit] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Tue, 28 Jun 2022 21:34:57 +0000 (16:34 -0500)]
PackWriter_remote: init remote_closed in __new__, not __init__
So that it's always set during __del__. Otherwise it might not exist
if (for example) __new__ or the superclass methods throw an exception
before we get to __init__.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Fri, 24 Jun 2022 21:14:43 +0000 (16:14 -0500)]
io.mmap: init _bup_closed in __new__, not __init__
So that it's always set during __del__. Otherwise it might not exist
if (for example) __new__ or the superclass methods throw an exception
before we get to __init__.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sat, 9 Jul 2022 18:15:53 +0000 (13:15 -0500)]
configure.inc: fix LDFLAGS validation
Change the CFLAGS validation to create ngc$$ instead of ngc$$.o since
it doesn't specify -c.
Change the LDFLAGS validation to create the .o file it needs.
Previously it relied on the CFLAGS test, which was optional, to do
that, and the CFLAGS test was actually creating an executable, not an
object file.
Thanks to Greg Troxel for reporting the omission.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sun, 10 Jul 2022 22:44:43 +0000 (17:44 -0500)]
test-sparse-files: increase the test size for macos/afs
When the cirrus tests moved to monterey test-sparse-files started
failing in "sparse file restore --sparse (sparse middle)" because the
restore_size was 28 and so greater than the expected 20.
Guessing that this might just be due to higher fixed-costs, I doubled
the sparse region data_size, and that did allow the tests to pass.
While the diagnosis might or might not be correct, the change
shouldn't materially affect the tests' effectiveness.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sat, 9 Jul 2022 22:17:59 +0000 (17:17 -0500)]
cirrus: update freebsd python, debian to bullseye, macos to monterey
Move freebsd python to 3.9, and update the debian and macos images.
Don't install rsnapshot on debian since it's not in bullseye, and the
one test doesn't actually rely on it.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
cmd/lib/bup.c: Don't use sysctl kern.proc.pathname on NetBSD
This doesn't work, and I have no idea why the code asks for it.
Removing NetBSD from this ifdef branch makes executing bup within the
build tree work again.
Signed-off-by: Greg Troxel <gdt@lexort.com> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sun, 1 May 2022 19:17:27 +0000 (14:17 -0500)]
Add test-comparative-split-join to test against another bup
Add a test that will test the split/join behavior (including a
detailed repository/packfile comparison) with randomized data against
another version of bup, provided BUP_TEST_OTHER_BUP is set to the path
of a bup executable.
Among other things, this should provide a top-level backstop with
respect to changes in the hashsplitter.
Use this to test against the default debian and homebrew bup packages
in cirrus.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Fri, 24 Jun 2022 21:36:04 +0000 (16:36 -0500)]
PackWriter: respect umask/sgid/etc. when creating pack/idx
Use atomically_replaced_file to ensure that the new packfile and index
respect the current umask, any directory sgid bit, etc., and use an
ExitStack to try to make sure all the corner cases are covered.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Fri, 24 Jun 2022 21:36:04 +0000 (16:36 -0500)]
hlinkdb: respect umask/sgid/etc. when creating new db
Use atomically_replaced_file to ensure that the new db respects the
current umask, any directory sgid bit, etc., and use an ExitStack to
try to make sure all the corner cases are covered.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Fri, 24 Jun 2022 21:18:33 +0000 (16:18 -0500)]
index.Writer: respect umask/sgid/etc. when creating new index
Use atomically_replaced_file to ensure that the new index respects the
current umask, any directory sgid bit, etc., and use an ExitStack to
try to make sure all the corner cases are covered.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Sun, 24 Jan 2021 20:35:34 +0000 (21:35 +0100)]
ftp: clean up error handling
We don't want to abort on errors since this is an interactive
tool; while at it, also clean up duplicate error reporting on
errors in 'ls' and weird bytes formatting on errors.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: let unexpected exceptions propgate]
[rlb@defaultvalue.org: use str for exception messages]
[rlb@defaultvalue.org: render paths via path_msg()]
[rlb@defaultvalue.org: add match_rx_grp and test for expected output] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Mon, 3 Jan 2022 18:41:59 +0000 (19:41 +0100)]
fuse: detect fusepy module
When importing 'fuse', we might get either the libfuse or
the fusepy module, the latter doesn't have __version__ so
we just print
error: fuse module is too old for fuse.__version__
but that's misleading. Detect if we have fuse.FUSE and in
that case instead print
error: fuse module appears to be fusepy, not python-fuse
please install https://github.com/libfuse/python-fuse
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: adjust commit message and error messages] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Tue, 17 Dec 2019 23:07:39 +0000 (00:07 +0100)]
git: return guessed value from guess_repo()
Return the value instead of storing it in a global, that makes
it easier to use elsewhere in the future.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: rm guess_repo argument] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Fri, 22 Oct 2021 19:10:22 +0000 (21:10 +0200)]
git.PackWriter: assert on no precalculated sha
We really don't have any code path getting here without
a sha, so don't try to make up for it if it's missing,
just assert.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Fri, 24 Jun 2022 16:41:36 +0000 (11:41 -0500)]
atomically_replaced_file: respect umask/sgid/etc. via tmpdir
Don't create the tempfile via mkstemp because it always creates files
with restricted permissions, which is not what we want for a new
packfile (for example). The replacement files should respect the
environment umask, directory sgid bits, etc.
Instead, create a normally open()ed file in a mkdtemp directory in the
same directory as the target path. Don't use TemporaryDirectory
because it's a @contextmanager (see below).
Add a missing '+' to the midx open mode. Without it mmap_readwrite's mmap
will fail with EACCES. This wasn't an issue with the previous
implementation because mkstemp doesn't accept a full mode string.
Also drop @contextmanager. Because it involves a generator,
@contextmanager creates managers that are incompatible with
ExitStack.pop_all() because they close during that call -- exactly
what pop_all() is intended to avoid.
Rob Browning [Fri, 24 Jun 2022 16:17:48 +0000 (11:17 -0500)]
Drop @contextmanager from finalized() and buptest
Because it involves a generator, @contextmanager creates managers that
are incompatible with ExitStack.pop_all() because they close during
that call -- exactly what pop_all() is intended to avoid.
So begin dropping @contextmanager in preference to explicit context
management classes/methods.
Rob Browning [Sun, 22 May 2022 17:20:10 +0000 (12:20 -0500)]
Respect/prefer/remember user specified CPPFLAGS/CFLAGS/LDFLAGS
While we remembered a configure-time CC, we didn't do the same for
other common user specified build variables, i.e. CPPFLAGS, CFLAGS,
and LDFLAGS. Fix that, and arrange for the user's values to come
last so that they can override the configuration values.
This matches expectations established by other tools, in particular
autoconf/automake, and avoids having to remember to specify overrides
to every invocation of make.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Muh Muhten [Thu, 26 May 2022 05:07:47 +0000 (01:07 -0400)]
pwdgrp.Group: allow gr_passwd to be None
I haven't looked into this too closely, but it seems that Android's
getgr* fill gr_passwd with a null pointer, mapped to python None, which
is not a bytes.
Since this assert seems to be 100% py3 sanity-checking and bup doesn't
actually use the gr_passwd anywhere, it should be safe to pass the None.
Muh Muhten [Thu, 26 May 2022 05:08:09 +0000 (01:08 -0400)]
Copy python-proposed instead of hardlink to python
In the unlikely event that we're building on a filesystem that doesn't
support hard links, ln fails gratuitously, while copying probably still
works. The python wrapper is normally pretty small.
Muh Muhten [Fri, 24 Jun 2022 03:45:41 +0000 (23:45 -0400)]
fix unfinished read on tag commits found in vfs cache
tag_item was not reading through repo.cat iterator after grabbing the
item type, leaving an in-progress read when listing tags after a
cached access to the commit referred by the tag. This manifests as an
AssertionError on `bup ls branch .tag` or similar vfs-consuming
command, or the bup fuse fs becoming almost completely unusable after
this access pattern as it errors EINVAL upon any attempt to read new
data from the repo! Resolve this by checking the cache up-front
before we do any reading.
Signed-off-by: Muh Muhten <muh.muhten@gmail.com> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Tue, 3 May 2022 00:54:54 +0000 (19:54 -0500)]
Disallow argc < 1 (for now just crash)
Since argc is allowed to be zero, and it's possible that any number of
things haven't been written to handle it, just crash for now if we
encounter it.
cf. https://lwn.net/Articles/882799/
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sat, 8 Jan 2022 18:04:59 +0000 (12:04 -0600)]
Drop support for python 2
Don't make broad, disruptive changes for now, but disallow python 2 in
./configure, adjust the docs, and remove code where it's unlikely to
cause conflicts with other pending changes.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Fri, 27 Aug 2021 22:56:24 +0000 (00:56 +0200)]
pylint: enable super-init-not-called
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Thu, 30 Dec 2021 20:31:55 +0000 (21:31 +0100)]
tag: use git.update_ref()
Even tag refs can be packed by git, so writing to a file
might cause issues. Call git update-ref for tags as well.
In order to do that properly (and allow 'bup tag' to keep
its ability to modify tags), change git.update_ref() to
take a 'force' argument that allows updating a ref even
if it already exists with an old value we don't know.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Wed, 24 Nov 2021 20:42:34 +0000 (21:42 +0100)]
Fail the tests if we detect any AssertionErrors
This exposed various problems in the recent contextmanagement work,
e.g. the assertions in the __del__ methods had been failing. Of
course this means that from now on, asserts should only be used to
detect fatal problems.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: adjust commit message] Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sat, 1 Jan 2022 17:13:41 +0000 (11:13 -0600)]
Client: make close durable; clean up partitial initializations
Always call close after any __init__ errors, and make sure close
always tries to clean up everything that's been initialized so far.
This fixes a __del__ complaint exposed when using the mmap wrapper in
py3.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Sun, 5 Dec 2021 20:19:52 +0000 (21:19 +0100)]
PackWriter._end: always try to release objcache and parentfd
Move the self.file guard inside the contextmanager.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: split from larger commit; adjust commit message] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Sun, 5 Dec 2021 20:19:52 +0000 (21:19 +0100)]
Context manage connections (via BaseConn)
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: split from larger commit; adjust commit message]
[rlb@defaultvalue.org: add pending_raise to exit handler] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Sun, 5 Dec 2021 20:19:52 +0000 (21:19 +0100)]
PackWriter_Remote.close: call parent close
We weren't explicitly closing the PackWriter, and __del__ no longer
does either. Make PackWriter a "new style" object so that the super()
call will also work with python 2.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: split from larger commit; adjust commit message]
[rlb@defaultvalue.org: convert PackWriter to "new style" object] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Sun, 5 Dec 2021 20:19:52 +0000 (21:19 +0100)]
NoOpContextManager: fix init/close/__del__ logic
Initialize self.closed, etc.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: split from larger commit; adjust commit message] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
[rlb@defaultvalue.org: split from larger commit; adjust commit message] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Sun, 5 Dec 2021 20:32:14 +0000 (21:32 +0100)]
test_index: don't create an extra writer
This was erroneously left over when changing to
context management, and my (new?) version of pytest
started warning on it.
Fixes: f26a6a9ec9d7 ("index.Writer.__del__: replace with context management") Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Thu, 25 Nov 2021 10:12:27 +0000 (12:12 +0200)]
git: PackIdxList: close extra packs when refreshing
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: defer list/sort until after closes] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Sun, 28 Nov 2021 19:49:13 +0000 (20:49 +0100)]
test-fuse: improve/broaden applicability checks
The 'fuse' group doesn't exist on (most?) modern distros
anymore, so checking for it and membership results in not
being able to run the tests.
Additionally, on some systems (e.g. Fedora) the wrong fuse
module is installed (there are at least two competing ones
in python with the name 'fuse'), so run 'bup fuse -h' at
the beginning of the test just to do the import checks.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: rebase onto WVSKIP addition]
[rlb@defaultvalue.org: adjust commit summary] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sat, 4 Dec 2021 18:32:50 +0000 (12:32 -0600)]
Teach pytest to handle WVSKIP and use it where we can
Have pytest scan the wvtest output for skip messages, and for now,
treat the whole test as skipped if we find any. This means that
for now WVSKIP can only be used as an up-front guard, but that's all
we need in most cases.
This should help make it more likely that we'll notice when tests are
unexpectedly skipped.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Sun, 28 Nov 2021 20:03:01 +0000 (21:03 +0100)]
pylint: enable syntax-error
This could be useful to catch issues early, and only the
py2raise module has errors now, so ignore it.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Tue, 30 Nov 2021 20:23:05 +0000 (21:23 +0100)]
random: use helpers.istty1
The helpers.istty1 variable can be used in place of the
same conditions open-coded here.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Tue, 30 Nov 2021 20:20:53 +0000 (21:20 +0100)]
main: treat BUP_FORCE_TTY as bitmap
We treat BUP_FORCE_TTY from the environment as a bitmap
all the time, so do the same in main. This requires an
update to one of the tests using it, but otherwise it's
supposed to be internal API, i.e. not documented in the
man page or such.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Mon, 22 Nov 2021 20:34:29 +0000 (21:34 +0100)]
main: fix output string truncation
There's a bug here that causes output to be cut off if it's
if the line was too long, in that case 'width' chars would
be removed at the beginning, rather than actually showing
'width' chars. Fix that.
Reported-by: Nix <nix@esperi.org.uk> Fixes: 00fb1f1b2a53 ("Clean subprocess output without newliner") Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Tue, 30 Nov 2021 20:26:22 +0000 (21:26 +0100)]
main: always put BUP_FORCE_TTY into the environment
Nix reports that progress output from midx/bloom while save
is running is no longer printed.
The reason turns out to be somewhat complicated:
* midx/bloom progress output is printed directly from the C
code, if stderr is known to be a tty from isatty(2) or the
environment variable BUP_FORCE_TTY
* save is a built-in command now, and so are midx/bloom (but
the latter is less relevant)
* a process inherits the environment that the parent has,
unless otherwise specified
So with the _old_ setup (with save not a module but process),
when save is started, main would set both BUP_FORCE_TTY (and
BUP_TTY_WIDTH) in the environment for the subprocess, causing
save to obtain it, and further midx/bloom to inherit it from
save. One of the downsides of this setup is that the size of
the window is now fixed, so resizing doesn't update.
With the _new_ setup, where save is a module, we don't set
BUP_FORCE_TTY or BUP_TTY_WIDTH in the environment since the
redirection and fixing etc. all happens in the main, and the
code is directly accessing stdout/stderr via the filtering.
The problem now is the following:
1) We create the filter thread, so that stdout/stderr are
no longer pointing to the real tty fd, so that isatty()
returns false. This is fine for save, or when we start
bloom/midx directly, as the _helpers.c istty2 has been
evaluated already before we redirect the fds.
2) As described, we don't set the environment variables
when we run the save code, since it's a module.
However, as a result, when save starts midx/bloom as a new
subprocess, they inherit the redirected fds, so that they're
not writing to the tty themselves, but also don't get the
environment variable BUP_FORCE_TTY since they're started by
save and that was a module.
The solution then is fairly simple: set both BUP_FORCE_TTY
and BUP_TTY_WIDTH in the environment unconditionally. The
latter is necessary so that options._tty_width() works in
the module-based commands as well.
This didn't just affect save -> midx/bloom, but also the ssh
calls that pass BUP_FORCE_TTY/BUP_TTY_WIDTH to the remote
process, so potentially the server's debug output was also
affected. Nix reported that the client debug output was not
shown ("Receiving index from server: %d/%d\r"), but I don't
have an explanation for that related to this commit, as that
code is actually running in the process of the save, thus
should be shown depending on helpers.istty2, which was
always correct in the main process.
Also, I'll note that we now always put BUP_FORCE_TTY into
the environment, which we avoided previously for some calls.
However, prior to the change to have most things be modules,
we were also doing that, since everything we called (git and
other tools like par2) would be started by a subprocess, so
this doesn't really seem to pose any danger.
Reported-by: Nix <nix@esperi.org.uk> Fixes: 5dd0172dddb9 ("bup: filter stdout/stderr via thread/pipe for internal subcommands") Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: remove now unused merge_dict from imports] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Thu, 25 Nov 2021 10:56:10 +0000 (12:56 +0200)]
git: close PackIdxList on init failures
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: use pending_raise] Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Mon, 22 Nov 2021 20:03:26 +0000 (14:03 -0600)]
bloom.do_bloom: always close filter; fix None vs 0 tests
Running a "split -n" for a larger file caused the assertion in
ShaBloom.__del__ to fail, i.e. the filter hadn't been explicitly
closed. Fix the logic in do_bloom to be careful about 0 vs None since
ShaBloom has a __len__ method, and add one missing explicit close().
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sun, 24 Oct 2021 17:24:16 +0000 (12:24 -0500)]
Check that all context managed objects are properly closed
Ensure all of our context managed objects have a __del__ that asserts
that the instance has been properly closed so that we'll be more
likely to notice related oversights.
This will only work in cases where __del__ is called before shutdown,
but that should normally be the case for cpython.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Tue, 28 Sep 2021 05:32:37 +0000 (00:32 -0500)]
CatPipe.__del__: replace with context management
Drop AbortableIter since CatFile is the only user, in favor of just
closing the catpipe (what the AbortableIter was doing) in the get()
exception handler.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sun, 17 Oct 2021 17:17:36 +0000 (12:17 -0500)]
ShaBloom.__del__: replace with context management
These changes also just use finally in some cases, instead of the more
complex py2 compatible BaseException/with_pending_raise() catch becase
I'm leaning in favor of just dropping python 2 support soon.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>