equal
deleted
inserted
replaced
164 return path |
164 return path |
165 |
165 |
166 _maxstorepathlen = 120 |
166 _maxstorepathlen = 120 |
167 _dirprefixlen = 8 |
167 _dirprefixlen = 8 |
168 _maxshortdirslen = 8 * (_dirprefixlen + 1) - 4 |
168 _maxshortdirslen = 8 * (_dirprefixlen + 1) - 4 |
169 def _hybridencode(path, auxencode): |
169 def _hybridencode(path, dotencode): |
170 '''encodes path with a length limit |
170 '''encodes path with a length limit |
171 |
171 |
172 Encodes all paths that begin with 'data/', according to the following. |
172 Encodes all paths that begin with 'data/', according to the following. |
173 |
173 |
174 Default encoding (reversible): |
174 Default encoding (reversible): |
195 The extension (e.g. '.i' or '.d') is preserved. |
195 The extension (e.g. '.i' or '.d') is preserved. |
196 |
196 |
197 The string 'data/' at the beginning is replaced with 'dh/', if the hashed |
197 The string 'data/' at the beginning is replaced with 'dh/', if the hashed |
198 encoding was used. |
198 encoding was used. |
199 ''' |
199 ''' |
200 res = '/'.join(auxencode(encodefilename(path).split('/'))) |
200 ef = encodefilename(path).split('/') |
|
201 res = '/'.join(_auxencode(ef, dotencode)) |
201 if len(res) > _maxstorepathlen: |
202 if len(res) > _maxstorepathlen: |
202 path = encodedir(path) |
203 path = encodedir(path) |
203 digest = _sha(path).hexdigest() |
204 digest = _sha(path).hexdigest() |
204 parts = auxencode(lowerencode(path).split('/')[1:]) |
205 le = lowerencode(path).split('/')[1:] |
|
206 parts = _auxencode(le, dotencode) |
205 basename = parts[-1] |
207 basename = parts[-1] |
206 _root, ext = os.path.splitext(basename) |
208 _root, ext = os.path.splitext(basename) |
207 sdirs = [] |
209 sdirs = [] |
208 sdirslen = 0 |
210 sdirslen = 0 |
209 for p in parts[:-1]: |
211 for p in parts[:-1]: |
440 self.fncache.write() |
442 self.fncache.write() |
441 |
443 |
442 def store(requirements, path, openertype): |
444 def store(requirements, path, openertype): |
443 if 'store' in requirements: |
445 if 'store' in requirements: |
444 if 'fncache' in requirements: |
446 if 'fncache' in requirements: |
445 auxencode = lambda f: _auxencode(f, 'dotencode' in requirements) |
447 de = 'dotencode' in requirements |
446 encode = lambda f: _hybridencode(f, auxencode) |
448 encode = lambda f: _hybridencode(f, de) |
447 return fncachestore(path, openertype, encode) |
449 return fncachestore(path, openertype, encode) |
448 return encodedstore(path, openertype) |
450 return encodedstore(path, openertype) |
449 return basicstore(path, openertype) |
451 return basicstore(path, openertype) |