Initialize _file in MetaStoreReader before open

So that __del__() will work properly if open fails.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
save-cmd.py: don't test for meta index via access()

Instead just try to open the metadata index and catch any EACCES.
There may be an issue with access on Cygwin
(http://bugs.python.org/issue2528), and even if not, this approach
removes a potential race between access() and open().

Thanks to Mark J Hewitt <mjh@idnet.com> for reporting the problem and
helping track down the cause.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
Ignore empty lines in --exclude-rx-from files

Thanks to Daniel Hahler Daniel Hahler <git@thequod.de> for suggesting
the change.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
parse_excludes: drop empty --exclude-from paths

Empty paths shouldn't match during drecurse, but there's no point in
including them.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
format-subst.pl: check for subcommand failure

Thanks to karl.richter722@gmail.com for reporting the problem.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
test-meta.sh: use user's uid/gid, not 0

Cygwin does not fully support uid and gid of 0. Instead, use the
current user's ids to avoid portability problems. Since this test is
not run for ordinary users, the result is the same.

Signed-off-by: Patrick Rouleau <prouleau72@gmail.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
Avoid uid/gid 0 metadata tests when ids don't exist

Cygwin may not have a 0 uid/gid, so skip the relevant tests whenever
it doesn't.

We have to explicitly exclude the gid 0 from other_group, because
/etc/group may define a group named root with the same id as
Administrators. We cannot use "root" instead of 0, because root may
not be defined.

Cygwin users: If you want to define the root group, add this line
at the begining of /etc/group:
  root:S-1-5-32-544:0:

Signed-off-by: Patrick Rouleau <prouleau72@gmail.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
test-fuse.sh: set TZ=UTC for ls dates

Thanks to Mark J Hewitt <mjh@idnet.com> and Scott Sugar
<scottsugar@outlook.com> for reporting the problem, and Patrick
Rouleau <prouleau72@gmail.com> for helping test the solution.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
HACKING: update to reflect 0.26 release

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
test-fuse.sh: use invariant test data

Thanks to Tim Riemenschneider <t.riemenschneider@detco.de> for
reporting the problem.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
Fix HEAD request handling in bup-web

HEAD requests to files did not set self.finished(). This causes problems
with user-agents that expect some type of request since it never closes
(OpenOffice/LibreOffice will notably stall opening files from a URL).

This patch stands alone from WebDAV but also fixes the problem there.

The problem can be demonstrated like this:

    bup web
    curl -I 'http://127.0.0.1:8080/some/file'

Signed-off-by: Will Rouesnel <w.rouesnel@gmail.com>
[rlb@defaultvalue.org: adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
Makefile: Rewrote so that 'make bup' can be up-to-date
Merge branch 'master' of https://github.com/bup/bup
Just log when skipping a large file during save

If bup-save --smaller= is specified, the user *expects* large files
to be skipped.  Having bup report errors and return exitcode 1 in this
case hides real errors.  Instead, log it when running verbosely, but
not otherwise.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
[rlb@defaultvalue.org: adjust commit summary; simplify opt.verbose >= 1
 to opt.verbose]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
Correct author for 497505901824dd7382d1d80e152f6b6d810a2844

The author for 497505901824dd7382d1d80e152f6b6d810a2844 was incorrect.
It should have been "Nick Alcock <nick.alcock@oracle.com>", matching
the Signed-off-by.

[rlb@defaultvalue.org: add correction on behalf of author]
Omit htonll when already #defined

OS X 10.10 Yosemite defines it as a macro.

Signed-off-by: R. Andrew Ohana <andrew.ohana@gmail.com>
[rlb@defaultvalue.org: adjust comments; adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
test-fuse.sh: make ls output locale independent

Call "ls" with LC_ALL set to "C".

(Otherwise it reports "total" for English, "insgesamt" for German;
other locales would be similar.)

Signed-off-by: Tim Riemenschneider <git@tim-riemenschneider.de>
[rlb@defaultvalue.org: adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
Add atomically_replaced_file for safer output

Use `tempfile.mkstemp` to write files safely and then rename them
atomically to the target filename at the end. This guarantees that two
concurrent processes trying to write the same target file will result
in one process "winning" with a consistent version.

Use this to protect:
 * midx writing
 * .idx cache writing

Previously both of these processes `open(destination + '.tmp', 'w')`
which would lead to concurrent processes writing the same tmp file at
the same time.

See also https://groups.google.com/d/msg/bup-list/qdPUaXGO1cI/g8K2aFaaXz0J

Signed-off-by: Nathan Bird <ecthellion@gmail.com>
[rlb@defaultvalue.org: adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
Adjust atomically_replaced_file documentation.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
thelpers.py: use t/tmp as the tmpdir parent

Signed-off-by: Rob Browning <rlb@defaultvalue.org>