design.txt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. chunk_cache
  2. bandstore
  3. dedupestore => dds
  4. init command
  5. TODO
  6. ----
  7. * Remote stores
  8. * Stat and chunk cache
  9. DONE
  10. ----
  11. * Encryption
  12. * Hard links
  13. * cache redesign
  14. * Symbolic links
  15. * Owner, group, mode, ctime, mtime
  16. cache = Cache(path,)
  17. for file in files:
  18. chunks = chunkify(file)
  19. for chunk in chunkify(file):
  20. if chunk.sha in cache:
  21. cache.chunk_inc_ref(chunk)
  22. else:
  23. fs.add_chunk(chunk)
  24. entry = Entry
  25. archive.add(entry)
  26. Repository layout
  27. -----------------
  28. REPO/README
  29. REPO/VERSION
  30. REPO/tid = x
  31. REPO/data/
  32. REPO/txn-active/tid
  33. REPO/txn-active/add/<PATH>/
  34. REPO/txn-active/delete/<PATH>/
  35. REPO/txn-active/tid
  36. REPO/txn-commit/add/<PATH>/
  37. REPO/txn-commit/delete/<PATH>/
  38. REPO/archives/<ARCHIVENAME>
  39. REPO/blocks/XX/YY/XYZ
  40. txn_completed/add/<PATH>/
  41. txn_completed/delete/<PATH>/
  42. API
  43. ---
  44. """
  45. class Cache(object):
  46. def chunk_inc_ref(self, chunk):
  47. self.chunk_refcount.setdefault(chunk.sha, 0)
  48. self.chunk_refcount[chunk.sha] += 1
  49. def chunk_dec_ref(self, chunk):
  50. assert self.chunk_refcount.get(chunk.sha, 0) > 0
  51. self.chunk_refcount[chunk.sha] -= 1
  52. if self.chunk_refcount[chunk.sha] == 0:
  53. self.fs.delete_chunk(self.sha)
  54. txn = txn_begin()