Skip to content

Commit

Permalink
use BORG_* as file MAGIC, adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWaldmann committed May 13, 2015
1 parent 35d06af commit 159315e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion attic/_hashindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ typedef struct {
off_t data_len;
} HashIndex;

#define MAGIC "ATTICIDX"
#define MAGIC "BORG_IDX"
#define EMPTY _htole32(0xffffffff)
#define DELETED _htole32(0xfffffffe)
#define MAX_BUCKET_SIZE 512
Expand Down
5 changes: 3 additions & 2 deletions attic/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def init(self, repository, passphrase):


class KeyfileKey(AESKeyBase):
FILE_ID = 'ATTIC KEY'
FILE_ID = 'BORG_KEY'
TYPE = 0x00

@classmethod
Expand All @@ -230,7 +230,8 @@ def find_key_file(cls, repository):
filename = os.path.join(keys_dir, name)
with open(filename, 'r') as fd:
line = fd.readline().strip()
if line and line.startswith(cls.FILE_ID) and line[10:] == id:
if (line and line.startswith(cls.FILE_ID) and
line[len(cls.FILE_ID)+1:] == id):
return filename
raise KeyfileNotFoundError(repository._location.canonical_path(), get_keys_dir())

Expand Down
2 changes: 1 addition & 1 deletion attic/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .lrucache import LRUCache

MAX_OBJECT_SIZE = 20 * 1024 * 1024
MAGIC = b'ATTICSEG'
MAGIC = b'BORG_SEG'
TAG_PUT = 0
TAG_DELETE = 1
TAG_COMMIT = 2
Expand Down
6 changes: 4 additions & 2 deletions attic/testsuite/hashindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ def _generic_test(self, cls, make_value, sha):
self.assert_equal(len(cls.read(idx_name.name)), 0)

def test_nsindex(self):
self._generic_test(NSIndex, lambda x: (x, x), '369a18ae6a52524eb2884a3c0fdc2824947edd017a2688c5d4d7b3510c245ab9')
self._generic_test(NSIndex, lambda x: (x, x),
'861d6d60069ea45e39d36bed2bdc1d0c07981e0641955f897ac6848be429abac')

def test_chunkindex(self):
self._generic_test(ChunkIndex, lambda x: (x, x, x), 'ed22e8a883400453c0ee79a06c54df72c994a54eeefdc6c0989efdc5ee6d07b7')
self._generic_test(ChunkIndex, lambda x: (x, x, x),
'69464bd0ebbc5866b9f95d838bc48617d21bfe3dcf294682a5c21a2ef6b9dc0b')

def test_resize(self):
n = 2000 # Must be >= MIN_BUCKETS
Expand Down
2 changes: 1 addition & 1 deletion attic/testsuite/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MockArgs:
repository = Location(tempfile.mkstemp()[1])

keyfile2_key_file = """
ATTIC KEY 0000000000000000000000000000000000000000000000000000000000000000
BORG_KEY 0000000000000000000000000000000000000000000000000000000000000000
hqppdGVyYXRpb25zzgABhqCkaGFzaNoAIMyonNI+7Cjv0qHi0AOBM6bLGxACJhfgzVD2oq
bIS9SFqWFsZ29yaXRobaZzaGEyNTakc2FsdNoAINNK5qqJc1JWSUjACwFEWGTdM7Nd0a5l
1uBGPEb+9XM9p3ZlcnNpb24BpGRhdGHaANAYDT5yfPpU099oBJwMomsxouKyx/OG4QIXK2
Expand Down

0 comments on commit 159315e

Please sign in to comment.