equal
deleted
inserted
replaced
7 |
7 |
8 class ConnectorBase(object): |
8 class ConnectorBase(object): |
9 |
9 |
10 #chuncksize = 16384 |
10 #chuncksize = 16384 |
11 chuncksize = 1024*1024 |
11 chuncksize = 1024*1024 |
12 def BlobFromFile(self, filepath): |
12 def BlobFromFile(self, filepath, seed): |
13 s = md5.new() |
13 s = md5.new() |
14 blobID = s.digest() # empty md5, to support empty blob |
14 s.update(seed) |
|
15 blobID = self.SeedBlob(seed) |
15 with open(filepath, "rb") as f: |
16 with open(filepath, "rb") as f: |
16 while True: |
17 while blobID == s.digest(): |
17 chunk = f.read(self.chuncksize) |
18 chunk = f.read(self.chuncksize) |
18 if len(chunk) == 0: return blobID |
19 if len(chunk) == 0: return blobID |
19 blobID = self.AppendChunkToBlob(chunk, blobID) |
20 blobID = self.AppendChunkToBlob(chunk, blobID) |
20 s.update(chunk) |
21 s.update(chunk) |
21 if blobID != s.digest(): return None |
|
22 |
22 |