Commit Graph

525 Commits

Author SHA1 Message Date
Mitch Bigelow 5ceb67195c fix incorrect _ns variables 2016-03-31 23:56:54 +02:00
Mitch Bigelow 6260648266 file stats are packed with 'int_to_bigint' in the archive. Unpack these before passing to llfuse 2016-03-31 22:13:01 +02:00
Thomas Waldmann a051593bfe do not sleep for >60s while waiting for lock, fixes #773 2016-03-31 22:00:00 +02:00
Marian Beermann 4bc27690af Possible fix to silently skipping EIO and the like? #748 2016-03-16 01:43:30 +01:00
Thomas Waldmann a23f8b8860 Cache: fix exception handling in __init__, release lock, fixes #610 2016-02-07 23:51:10 +01:00
Thomas Waldmann 7e5d30f41a seeking to an invalid position is an IOError in python 3.2
python >= 3.3 raises OSError in this case.
2016-02-01 16:10:42 +01:00
Thomas Waldmann e2f5983eef finer repo check progress indicator
a step size of 5% was way too much, now doing 0.1%
2016-01-23 20:00:03 +01:00
Michael Hanselmann c7fb598ab9 Add shell-style pattern syntax
The fnmatch module in Python's standard library implements a pattern
format for paths which is similar to shell patterns. However, “*”
matches any character including path separators. This newly introduced
pattern syntax with the selector “sh” no longer matches the path
separator with “*”. Instead “**/” can be used to match zero or more
directory levels.
2016-01-21 16:07:24 +01:00
Michael Hanselmann 382b79212b Reformat pattern syntax descriptions as definition list
There are already three different styles and a fourth will be added.
A definition list is easier to navigate when trying to find the
description of a specific style.
2016-01-21 14:24:32 +01:00
TW 3496fc4665 Merge pull request #577 from Profpatsch/master
Fix upgrade without ~/attic/keys existing.
2016-01-20 00:52:30 +01:00
Profpatsch cf0262c8b4 Fix upgrade without ~/attic/keys existing.
fixes #576
2016-01-19 11:29:18 +01:00
Michael Hanselmann dad0ba9661 Remove old-style pattern handling functions
Remove the “adjust_pattern” and “exclude_path” functions and replace
them with the recently introduced pattern matcher class.
2016-01-18 21:26:08 +01:00
Michael Hanselmann ceae4a9fa8 Support patterns on extraction, fixes #361
This change implements the functionality requested in issue #361:
extracting files with a given extension. It does so by permitting
patterns to be used instead plain prefix paths. The pattern styles
supported are the same as for exclusions.
2016-01-18 21:26:08 +01:00
Michael Hanselmann 848375e2fe Add and document path prefix as pattern style
The “extract” command supports extracting all files underneath a given
set of prefix paths. The forthcoming support for extracting files using
a pattern (i.e. only files ending in “.zip”) requires the introduction
of path prefixes as a third pattern style, making it also available for
exclusions.
2016-01-18 21:26:08 +01:00
Michael Hanselmann b6362b5963 Flexible default pattern style
A function to parse pattern specifications was introduced in commit
2bafece. Since then it had a hardcoded default style of “fm”, meaning
fnmatch. With the forthcoming support for extracting files using
patterns this default style must be more flexible.
2016-01-18 20:59:09 +01:00
Michael Hanselmann 1fa4d2e516 Use constants for pattern style prefixes
The prefix used for pattern styles should be kept together with the
respective style implementation.
2016-01-18 20:59:08 +01:00
Michael Hanselmann 190107ada7 Replace use of “exclude_path” in tests
The newly added pattern matcher class can replace the “exclude_path”
function. The latter is going to be removed in a later change.
2016-01-18 20:59:08 +01:00
Michael Hanselmann 9747755131 Add pattern matcher wrapper
The utility functions “adjust_patterns” and “exclude_path” produce
respectively use a standard list object containing pattern objects.
With the forthcoming introduction of patterns for filtering files
to be extracted it's better to move the logic of these classes into
a single class.

The wrapper allows adding any number of patterns to an internal list
together with a value to be returned if a match function finds that
one of the patterns matches. A fallback value is returned otherwise.
2016-01-18 20:59:08 +01:00
Michael Hanselmann c1feb4b532 Simplify pattern tests
- Stop using “adjust_pattern” and “exclude_path” as they're utility
  functions not relevant to testing pattern classes
- Cover a few more cases, especially with more than one path separator
  and relative paths
- At least one dedicated test function for each pattern style as opposed
  to a single, big test mixing styles
- Use positive instead of negative matching (i.e. the expected list of
  resulting items is a list of items matching a pattern)
2016-01-18 20:47:22 +01:00
TW 735fe557e2 Merge pull request #571 from ThomasWaldmann/fix-570
fix crash when using borg create --dry-run --keep-tag-files, fixes #570
2016-01-18 16:16:54 +01:00
Thomas Waldmann 4c00bb0d2f fix crash when using borg create --dry-run --keep-tag-files, fixes #570 2016-01-18 14:30:41 +01:00
TW f2f2810b5a Merge pull request #568 from ypid/docs-fixes
Docs fixes.
2016-01-18 11:02:13 +01:00
TW 1878e223d6 Merge pull request #566 from ThomasWaldmann/cache-ctxmgr
implement and use context manager for Cache, partial fix for #285
2016-01-18 01:00:17 +01:00
TW 704b505968 Merge pull request #565 from ThomasWaldmann/repocache-ctxmgr
Repocache ctxmgr
2016-01-18 00:58:23 +01:00
Robin Schneider 576348a9d4
Use HTTPS everywhere. Especially when the website already redirects to HTTPS. 2016-01-17 22:31:08 +01:00
Robin Schneider 1f1ff61375
borg prune only knows "--keep-within" and not "--within". 2016-01-17 21:15:26 +01:00
Thomas Waldmann 22f218baef implement and use context manager for Cache, partial fix for #285
also: make check in Lock.close more precise, check for "is not None".

note: a lot of blocks were just indented to be under the "with" statement,
in one case a block had to be moved into a function.
2016-01-17 01:15:42 +01:00
Thomas Waldmann 5ec2a3a49b use the RepositoryCache context manager also in fuse code 2016-01-17 00:30:00 +01:00
Thomas Waldmann 4d73f3cdb9 implement and use context manager for RepositoryCache, fixes #548 2016-01-17 00:30:00 +01:00
Thomas Waldmann 9198f6962c implement --progress option for borg delete <archive> 2016-01-16 20:46:49 +01:00
Thomas Waldmann 0213164d46 implement --progress option for borg upgrade, fixes #291 2016-01-16 20:32:24 +01:00
Thomas Waldmann e68b800d01 remove unused "repair" rpc method
there is no such method in the code.
we use "check" method to repair the repo, so maybe this was left over
from a time when repair was separate from check.
2016-01-16 18:58:52 +01:00
Thomas Waldmann 845d2144cb fix locking, partial fix for #502
the problem was that the borg process removed its own shared lock when upgrading it to an exclusive lock.
this is fine if we get the exclusive lock, but if we don't, we must re-add our shared lock.

this fixes the KeyError in locking.py:217
2016-01-16 18:03:58 +01:00
TW f35ba0b577 Merge pull request #559 from ThomasWaldmann/metastream-chunker
finer chunker granularity for items metadata stream, fixes #547, fixes #487
2016-01-15 22:42:20 +01:00
TW d248a7d537 Merge pull request #557 from hansmi/pattern-cleanup
Rename pattern classes and refactor tests
2016-01-15 21:50:04 +01:00
Thomas Waldmann 888e078382 use finer chunker granularity for items metadata stream, fixes #547, fixes #487
the items metadata stream is usually not that big (compared to the file content data) -
it is just file and dir names and other metadata.

if we use too rough granularity there (and big minimum chunk size), we usually will get no deduplication.
2016-01-15 20:56:21 +01:00
TW b8789f7bde Merge pull request #552 from ThomasWaldmann/hashtable-resizing
Hashtable resizing
2016-01-15 20:54:28 +01:00
Michael Hanselmann 3a39ddbd83 Rename pattern classes for consistency
The class names “IncludePattern” and “ExcludePattern” may have been
appropriate when they were the only styles. With the recent addition of
regular expression support and with at least one more style being added
in forthcoming changes these classes should be renamed to be more
descriptive. “ExcludeRegex” is also renamed to match the new names.
2016-01-15 17:16:25 +01:00
Michael Hanselmann 2c7ab8595d Refactor Unicode pattern tests
The unit tests for Unicode in path patterns contained a lot of
unnecessary duplication. One set of duplication was for Mac OS X (also
known as Darwin) as it normalizes Unicode in paths to NFD. Then each
test case was repeated for every type of pattern.

With this change the tests become parametrized using py.test. The
duplicated code has been removed.
2016-01-15 17:16:25 +01:00
Thomas Waldmann 96f88a29d2 add --list option for borg create
like --stats enables statistics output, --list enables the file/dirs list output.
2016-01-14 18:57:05 +01:00
Michael Hanselmann b6d0ee7c13 Capitalization fixes for upgrade help epilog 2016-01-14 17:04:34 +01:00
Thomas Waldmann 5cb47cbedd hashindex: explain hash_sizes 2016-01-14 14:39:59 +01:00
Thomas Waldmann 083f5e31ef hashindex: fix upper limit
use num_buckets (== fully use what we currently have allocated)
2016-01-14 14:39:59 +01:00
Thomas Waldmann 09665805e8 move func defs to avoid implicit declaration compiler warning 2016-01-14 14:39:59 +01:00
Thomas Waldmann 91cde721b4 hashindex: minor refactor
- rename BUCKET_(LOWER|UPPER)_LIMIT to HASH_(MIN|MAX)_LOAD
   as this value is usually called the hash table's minimum/maximum load factor.
- remove MAX_BUCKET_SIZE (not used)
- regroup/reorder definitions
2016-01-14 14:39:59 +01:00
Thomas Waldmann d88df3edc6 hashtable size follows a growth policy, fixes #527
also: refactor / dedupe some code into functions
2016-01-14 14:39:59 +01:00
TW 89169c3f87 Merge pull request #542 from ThomasWaldmann/fix-stats-logging
log stats consistently, fixes #526
2016-01-14 14:33:53 +01:00
Michael Hanselmann 2369b8a0f2 Strip whitespace when loading exclusions from file
Patterns to exclude files can be loaded from a text file using the
“--exclude-from” option. Whitespace at the beginning or end of lines was
not stripped. Indented comments would be interpreted as a pattern and
a misplaced space at the end of a line--some text editors don't strip
them--could cause an exclusion pattern to not match as desired. With the
recent addition of regular expression support for exclusions the spaces
can be matched if necessary (“^\s” or “\s$”), though it's highly
unlikely that there are many paths deliberately starting or ending with
whitespace.
2016-01-13 17:39:22 +01:00
Michael Hanselmann 2bafece093 Implement exclusions using regular expressions
The existing option to exclude files and directories, “--exclude”, is
implemented using fnmatch[1]. fnmatch matches the slash (“/”) with “*”
and thus makes it impossible to write patterns where a directory with
a given name should be excluded at a specific depth in the directory
hierarchy, but not anywhere else. Consider this structure:

  home/
  home/aaa
  home/aaa/.thumbnails
  home/user
  home/user/img
  home/user/img/.thumbnails

fnmatch incorrectly excludes “home/user/img/.thumbnails” with a pattern
of “home/*/.thumbnails” when the intention is to exclude “.thumbnails”
in all home directories while retaining directories with the same name
in all other locations.

With this change regular expressions are introduced as an additional
pattern syntax. The syntax is selected using a prefix on “--exclude”'s
value. “re:” is for regular expression and “fm:”, the default, selects
fnmatch. Selecting the syntax is necessary when regular expressions are
desired or when the desired fnmatch pattern starts with two alphanumeric
characters followed by a colon (i.e. “aa:something/*”). The exclusion
described above can be implemented as follows:

  --exclude 're:^home/[^/]+/\.thumbnails$'

The “--exclude-from” option permits loading exclusions from a text file
where the same prefixes can now be used, e.g. “re:\.tmp$”.

The documentation has been extended and now not only describes the two
pattern styles, but also the file format supported by “--exclude-from”.

This change has been discussed in issue #43 and in change request #497.

[1] https://docs.python.org/3/library/fnmatch.html

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
2016-01-13 17:39:19 +01:00
Michael Hanselmann 93c9c49250 Reduce code duplication in inclusion/exclusion pattern logic
The two classes for applying inclusion and exclusion patterns contained
unnecessarily duplicated logic. The introduction of a shared base class
allows for easier reuse, especially considering that two more classes
are going to be added in forthcoming changes (regular expressions and
shell-style patterns).
2016-01-13 14:35:59 +01:00