Browse Source

use BORG_* as file MAGIC, adapt tests

Thomas Waldmann 10 years ago
parent
commit
159315ef5d
5 changed files with 10 additions and 7 deletions
  1. 1 1
      attic/_hashindex.c
  2. 3 2
      attic/key.py
  3. 1 1
      attic/repository.py
  4. 4 2
      attic/testsuite/hashindex.py
  5. 1 1
      attic/testsuite/key.py

+ 1 - 1
attic/_hashindex.c

@@ -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

+ 3 - 2
attic/key.py

@@ -207,7 +207,7 @@ class PassphraseKey(AESKeyBase):
 
 
 class KeyfileKey(AESKeyBase):
-    FILE_ID = 'ATTIC KEY'
+    FILE_ID = 'BORG_KEY'
     TYPE = 0x00
 
     @classmethod
@@ -230,7 +230,8 @@ class KeyfileKey(AESKeyBase):
             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())
 

+ 1 - 1
attic/repository.py

@@ -13,7 +13,7 @@ from .helpers import Error, IntegrityError, read_msgpack, write_msgpack, unhexli
 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

+ 4 - 2
attic/testsuite/hashindex.py

@@ -44,10 +44,12 @@ class HashIndexTestCase(AtticTestCase):
         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

+ 1 - 1
attic/testsuite/key.py

@@ -15,7 +15,7 @@ class KeyTestCase(AtticTestCase):
         repository = Location(tempfile.mkstemp()[1])
 
     keyfile2_key_file = """
-        ATTIC KEY 0000000000000000000000000000000000000000000000000000000000000000
+        BORG_KEY 0000000000000000000000000000000000000000000000000000000000000000
         hqppdGVyYXRpb25zzgABhqCkaGFzaNoAIMyonNI+7Cjv0qHi0AOBM6bLGxACJhfgzVD2oq
         bIS9SFqWFsZ29yaXRobaZzaGEyNTakc2FsdNoAINNK5qqJc1JWSUjACwFEWGTdM7Nd0a5l
         1uBGPEb+9XM9p3ZlcnNpb24BpGRhdGHaANAYDT5yfPpU099oBJwMomsxouKyx/OG4QIXK2