mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-03 18:27:01 +00:00
Fix location parsing issue with short paths
This commit is contained in:
parent
cbfdedc329
commit
9630714fac
2 changed files with 14 additions and 6 deletions
|
@ -245,17 +245,17 @@ def group2gid(group):
|
|||
return None
|
||||
|
||||
|
||||
class Location(object):
|
||||
class Location:
|
||||
"""Object representing a repository / archive location
|
||||
"""
|
||||
proto = user = host = port = path = archive = None
|
||||
ssh_re = re.compile(r'(?P<proto>ssh)://(?:(?P<user>[^@]+)@)?'
|
||||
r'(?P<host>[^:/#]+)(?::(?P<port>\d+))?'
|
||||
r'(?P<path>[^:]*)(?:::(?P<archive>.+))?')
|
||||
r'(?P<path>[^:]+)(?:::(?P<archive>.+))?')
|
||||
file_re = re.compile(r'(?P<proto>file)://'
|
||||
r'(?P<path>[^:]*)(?:::(?P<archive>.+))?')
|
||||
r'(?P<path>[^:]+)(?:::(?P<archive>.+))?')
|
||||
scp_re = re.compile(r'((?:(?P<user>[^@]+)@)?(?P<host>[^:/]+):)?'
|
||||
r'(?P<path>[^:]*)(?:::(?P<archive>.+))?')
|
||||
r'(?P<path>[^:]+)(?:::(?P<archive>.+))?')
|
||||
|
||||
def __init__(self, text):
|
||||
self.orig = text
|
||||
|
|
|
@ -19,8 +19,16 @@ def test(self):
|
|||
"Location(proto='ssh', user='user', host='host', port=22, path='/some/path', archive='archive')"
|
||||
)
|
||||
self.assert_equal(
|
||||
repr(Location('/some/path::archive')),
|
||||
"Location(proto='file', user=None, host=None, port=None, path='/some/path', archive='archive')"
|
||||
repr(Location('mybackup.darc::archive')),
|
||||
"Location(proto='file', user=None, host=None, port=None, path='mybackup.darc', archive='archive')"
|
||||
)
|
||||
self.assert_equal(
|
||||
repr(Location('/some/absolute/path::archive')),
|
||||
"Location(proto='file', user=None, host=None, port=None, path='/some/absolute/path', archive='archive')"
|
||||
)
|
||||
self.assert_equal(
|
||||
repr(Location('some/relative/path::archive')),
|
||||
"Location(proto='file', user=None, host=None, port=None, path='some/relative/path', archive='archive')"
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue