Show More
@@ -130,22 +130,23 b' def _auxencode(path, dotencode):' | |||||
130 | basename (e.g. "aux", "aux.foo"). A directory or file named "foo.aux" |
|
130 | basename (e.g. "aux", "aux.foo"). A directory or file named "foo.aux" | |
131 | doesn't need encoding. |
|
131 | doesn't need encoding. | |
132 |
|
132 | |||
133 |
>>> |
|
133 | >>> s = '.foo/aux.txt/txt.aux/con/prn/nul/foo.' | |
|
134 | >>> _auxencode(s.split('/'), True) | |||
134 | ['~2efoo', 'au~78.txt', 'txt.aux', 'co~6e', 'pr~6e', 'nu~6c', 'foo~2e'] |
|
135 | ['~2efoo', 'au~78.txt', 'txt.aux', 'co~6e', 'pr~6e', 'nu~6c', 'foo~2e'] | |
135 |
>>> |
|
136 | >>> s = '.com1com2/lpt9.lpt4.lpt1/conprn/com0/lpt0/foo.' | |
|
137 | >>> _auxencode(s.split('/'), False) | |||
136 | ['.com1com2', 'lp~749.lpt4.lpt1', 'conprn', 'com0', 'lpt0', 'foo~2e'] |
|
138 | ['.com1com2', 'lp~749.lpt4.lpt1', 'conprn', 'com0', 'lpt0', 'foo~2e'] | |
137 | >>> _auxencode('foo. ', True) |
|
139 | >>> _auxencode(['foo. '], True) | |
138 | ['foo.~20'] |
|
140 | ['foo.~20'] | |
139 | >>> _auxencode(' .foo', True) |
|
141 | >>> _auxencode([' .foo'], True) | |
140 | ['~20.foo'] |
|
142 | ['~20.foo'] | |
141 | ''' |
|
143 | ''' | |
142 | res = path.split('/') |
|
144 | for i, n in enumerate(path): | |
143 | for i, n in enumerate(res): |
|
|||
144 | if not n: |
|
145 | if not n: | |
145 | continue |
|
146 | continue | |
146 | if dotencode and n[0] in '. ': |
|
147 | if dotencode and n[0] in '. ': | |
147 | n = "~%02x" % ord(n[0]) + n[1:] |
|
148 | n = "~%02x" % ord(n[0]) + n[1:] | |
148 |
|
|
149 | path[i] = n | |
149 | else: |
|
150 | else: | |
150 | l = n.find('.') |
|
151 | l = n.find('.') | |
151 | if l == -1: |
|
152 | if l == -1: | |
@@ -156,11 +157,11 b' def _auxencode(path, dotencode):' | |||||
156 | # encode third letter ('aux' -> 'au~78') |
|
157 | # encode third letter ('aux' -> 'au~78') | |
157 | ec = "~%02x" % ord(n[2]) |
|
158 | ec = "~%02x" % ord(n[2]) | |
158 | n = n[0:2] + ec + n[3:] |
|
159 | n = n[0:2] + ec + n[3:] | |
159 |
|
|
160 | path[i] = n | |
160 | if n[-1] in '. ': |
|
161 | if n[-1] in '. ': | |
161 | # encode last period or space ('foo...' -> 'foo..~2e') |
|
162 | # encode last period or space ('foo...' -> 'foo..~2e') | |
162 |
|
|
163 | path[i] = n[:-1] + "~%02x" % ord(n[-1]) | |
163 |
return |
|
164 | return path | |
164 |
|
165 | |||
165 | _maxstorepathlen = 120 |
|
166 | _maxstorepathlen = 120 | |
166 | _dirprefixlen = 8 |
|
167 | _dirprefixlen = 8 | |
@@ -196,11 +197,11 b' def _hybridencode(path, auxencode):' | |||||
196 | 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 | |
197 | encoding was used. |
|
198 | encoding was used. | |
198 | ''' |
|
199 | ''' | |
199 | res = '/'.join(auxencode(encodefilename(path))) |
|
200 | res = '/'.join(auxencode(encodefilename(path).split('/'))) | |
200 | if len(res) > _maxstorepathlen: |
|
201 | if len(res) > _maxstorepathlen: | |
201 | path = encodedir(path) |
|
202 | path = encodedir(path) | |
202 | digest = _sha(path).hexdigest() |
|
203 | digest = _sha(path).hexdigest() | |
203 | parts = auxencode(lowerencode(path))[1:] |
|
204 | parts = auxencode(lowerencode(path).split('/')[1:]) | |
204 | basename = parts[-1] |
|
205 | basename = parts[-1] | |
205 | _root, ext = os.path.splitext(basename) |
|
206 | _root, ext = os.path.splitext(basename) | |
206 | sdirs = [] |
|
207 | sdirs = [] |
General Comments 0
You need to be logged in to leave comments.
Login now