e.g.:
- setting any security.* key is expected to fail with EACCES if one is not root.
- issue #162 on our issue tracker: user was root, but due to some specific scenario
involving docker and selinux, setting security.selinux key fails even when running as root
not sure if it is the best solution to silently ignore this, but some lines below this change
failure to do a chown is also silently ignored (happens e.g. when restoring a file not owned
by the current user as a non-root user).
if we use {} as default for item.get(), we do not need the "if" as iteration over an empty dict won't do anything.
also fixes too deep indentation the original code had.
the parser for the --chunker-params argument had a wrong parameter order.
fixed the order so it conforms to the help text and the docs.
also added some tests for it and a text for the ValueError exception.
currently, we only use sha256 hashes as key, so key length is always 32.
but instead of hardcoding 32 everywhere, using key_length is just better
readable and also more flexible for the future.
borg list --short just spills out the list of files / dirs - better for some tests
and also useful on the commandline for interactive use.
the tests previously needed fakeroot because in the test setup it always
made calls to mknod and chown, which require (fake)root.
now, the tests adapt to whether it detects (fake)root or not - to run the
the tests completely, you still need fakeroot, but it won't fail all the archiver
tests just due to failing test setup.
also, a test not working correctly due to fakeroot was found:
it should detect whether a read-only repo is usable, but it failed to do that
because with (fake)root, there is no "read only" (at least not via taking away
the w permission bits).
environment context manager: if a env var was not present before, it should not be present afterwards
teardown: cd out of the tmpdir before deleting it
I re-wrote lrucache (and it seems like no-one had looked at it much
before :). I was told my test function would have been simpler in
native py.test, so let's have a go converting it all.
We can avoid any reference to unittest, because lrucache doesn't write
files so it doesn't need any of our custom assertion helpers.
dict.pop() will raise KeyError for us if necessary. I was confused
because we used to have lrucache.pop() with a bug, that returned None
instead.
Great catch by @ThomasWaldmann.
At least one programmer is confused by my abuse of KeyError()
as a sentinel value. Let's call the sentinel value _NotFound
instead, and let's avoid re-creating it on each call.
I have a new favourite line of code, "if item is _NotFound" :).
Thanks to @ThomasWaldmann for all these review suggestions.
We need to make sure dispose() is always called when necessary.
Using inheritance it's just too easy to forget a method,
that we needed to override.
I also find it confusing when an override method calls another
method, and you have yet to see whether the latter method is
overridden or not. It didn't help that most of these methods
are actually operator overloads.
This turns out to require _less_ code :-).
(Admittedly the code could have been reduced a bit anyway
because python3's super() can be called without any arguments).
The initializer now takes a dispose function. lrucache
claims ownership of the items it contains and will dispose
deleted items. Ownership can naturally be reclaimed by calling
pop() for the item.
Suggested by @ThomasWaldmann. Avoiding a complex assumption
should make the code easier to understand and maintain.
(Technically we do have an fd for the segment, because
the only caller opens the segment and checks it before
calling for repair.)
found out why it could not install llfuse into virtual env: it always complained about
not being able to find fuse.pc - which is part of libfuse-dev / fuse-devel and was missing.
once one adds the fuse dev stuff, llfuse installs to virtual env without problems.