Browse Source

Renamed crypt.py to crypto.py

Jonas Borgström 14 years ago
parent
commit
b16885046a
4 changed files with 20 additions and 20 deletions
  1. 13 13
      dedupestore/archive.py
  2. 3 3
      dedupestore/archiver.py
  3. 4 4
      dedupestore/cache.py
  4. 0 0
      dedupestore/crypto.py

+ 13 - 13
dedupestore/archive.py

@@ -6,7 +6,7 @@ import sys
 
 from .cache import NS_ARCHIVES, NS_CHUNKS, NS_CINDEX
 from .chunkifier import chunkify
-from .crypt import CryptoManager
+from .crypto import CryptoManager
 from .helpers import uid2user, user2uid, gid2group, group2gid
 
 CHUNK_SIZE = 55001
@@ -15,30 +15,30 @@ CHUNK_SIZE = 55001
 class Archive(object):
 
     def __init__(self, store, name=None):
-        self.crypt = CryptoManager(store)
+        self.crypto = CryptoManager(store)
         self.store = store
         self.items = []
         self.chunks = []
         self.chunk_idx = {}
         self.hard_links = {}
         if name:
-            self.load(self.crypt.id_hash(name))
+            self.load(self.crypto.id_hash(name))
 
     def load(self, id):
         self.id = id
-        archive = self.crypt.unpack_read(self.store.get(NS_ARCHIVES, self.id))
+        archive = self.crypto.unpack_read(self.store.get(NS_ARCHIVES, self.id))
         if archive['version'] != 1:
             raise Exception('Archive version %r not supported' % archive['version'])
         self.items = archive['items']
         self.name = archive['name']
-        cindex = self.crypt.unpack_create(self.store.get(NS_CINDEX, self.id))
+        cindex = self.crypto.unpack_create(self.store.get(NS_CINDEX, self.id))
         assert cindex['version'] == 1
         self.chunks = cindex['chunks']
         for i, chunk in enumerate(self.chunks):
             self.chunk_idx[i] = chunk[0]
 
     def save(self, name):
-        self.id = self.crypt.id_hash(name)
+        self.id = self.crypto.id_hash(name)
         archive = {
             'version': 1,
             'name': name,
@@ -46,15 +46,15 @@ class Archive(object):
             'ts': datetime.utcnow().isoformat(),
             'items': self.items,
         }
-        data = self.crypt.pack_read(archive)
+        data = self.crypto.pack_read(archive)
         self.store.put(NS_ARCHIVES, self.id, data)
         cindex = {
             'version': 1,
             'chunks': self.chunks,
         }
-        data = self.crypt.pack_create(cindex)
+        data = self.crypto.pack_create(cindex)
         self.store.put(NS_CINDEX, self.id, data)
-        self.crypt.store_key()
+        self.crypto.store_key()
         self.store.commit()
 
     def add_chunk(self, id, size):
@@ -118,7 +118,7 @@ class Archive(object):
                     for chunk in item['chunks']:
                         id = self.chunk_idx[chunk]
                         try:
-                            fd.write(self.crypt.unpack_read(self.store.get(NS_CHUNKS, id)))
+                            fd.write(self.crypto.unpack_read(self.store.get(NS_CHUNKS, id)))
                         except ValueError:
                             raise Exception('Invalid chunk checksum')
                 self.restore_stat(path, item)
@@ -146,7 +146,7 @@ class Archive(object):
                 for chunk in item['chunks']:
                     id = self.chunk_idx[chunk]
                     try:
-                        self.crypt.unpack_read(self.store.get(NS_CHUNKS, id))
+                        self.crypto.unpack_read(self.store.get(NS_CHUNKS, id))
                     except ValueError:
                         logging.error('%s ... ERROR', item['path'])
                         break
@@ -243,12 +243,12 @@ class Archive(object):
         })
 
     def process_chunk(self, data, cache):
-        id = self.crypt.id_hash(data)
+        id = self.crypto.id_hash(data)
         try:
             return self.chunk_idx[id]
         except KeyError:
             idx = len(self.chunks)
-            size = cache.add_chunk(id, data, self.crypt)
+            size = cache.add_chunk(id, data, self.crypto)
             self.chunks.append((id, size))
             self.chunk_idx[id] = idx
             return idx

+ 3 - 3
dedupestore/archiver.py

@@ -20,7 +20,7 @@ class Archiver(object):
     def do_create(self, args):
         store = self.open_store(args.archive)
         archive = Archive(store)
-        cache = Cache(store, archive.crypt)
+        cache = Cache(store, archive.crypto)
         archive.create(args.archive.archive, args.paths, cache)
         return self.exit_code_from_logger()
 
@@ -33,7 +33,7 @@ class Archiver(object):
     def do_delete(self, args):
         store = self.open_store(args.archive)
         archive = Archive(store, args.archive.archive)
-        cache = Cache(store, archive.crypt)
+        cache = Cache(store, archive.crypto)
         archive.delete(cache)
         return self.exit_code_from_logger()
 
@@ -56,7 +56,7 @@ class Archiver(object):
     def do_info(self, args):
         store = self.open_store(args.archive)
         archive = Archive(store, args.archive.archive)
-        cache = Cache(store, archive.crypt)
+        cache = Cache(store, archive.crypto)
         osize, csize, usize = archive.stats(cache)
         print 'Original size:', pretty_size(osize)
         print 'Compressed size:', pretty_size(csize)

+ 4 - 4
dedupestore/cache.py

@@ -11,14 +11,14 @@ class Cache(object):
     """Client Side cache
     """
 
-    def __init__(self, store, crypt):
+    def __init__(self, store, crypto):
         self.store = store
         self.path = os.path.join(os.path.expanduser('~'), '.dedupestore', 'cache',
                                  '%s.cache' % self.store.uuid)
         self.tid = -1
         self.open()
         if self.tid != self.store.tid:
-            self.init(crypt)
+            self.init(crypto)
 
     def open(self):
         if not os.path.exists(self.path):
@@ -33,7 +33,7 @@ class Cache(object):
         self.chunkmap = cache['chunkmap']
         self.tid = cache['tid']
 
-    def init(self, crypt):
+    def init(self, crypto):
         """Initializes cache by fetching and reading all archive indicies
         """
         logging.info('Initializing cache...')
@@ -42,7 +42,7 @@ class Cache(object):
         if self.store.tid == 0:
             return
         for id in list(self.store.list(NS_CINDEX)):
-            cindex = crypt.unpack_create(self.store.get(NS_CINDEX, id))
+            cindex = crypto.unpack_create(self.store.get(NS_CINDEX, id))
             for id, size in cindex['chunks']:
                 try:
                     count, size = self.chunkmap[id]

+ 0 - 0
dedupestore/crypt.py → dedupestore/crypto.py