40 # 64 bytes for SHA256 |
44 # 64 bytes for SHA256 |
41 _lfsre = re.compile(br'\A[a-f0-9]{64}\Z') |
45 _lfsre = re.compile(br'\A[a-f0-9]{64}\Z') |
42 |
46 |
43 |
47 |
44 class lfsvfs(vfsmod.vfs): |
48 class lfsvfs(vfsmod.vfs): |
45 def join(self, path): |
49 def join(self, path: Optional[bytes], *insidef: bytes) -> bytes: |
46 """split the path at first two characters, like: XX/XXXXX...""" |
50 """split the path at first two characters, like: XX/XXXXX...""" |
47 if not _lfsre.match(path): |
51 if not _lfsre.match(path): |
48 raise error.ProgrammingError(b'unexpected lfs path: %s' % path) |
52 raise error.ProgrammingError(b'unexpected lfs path: %s' % path) |
49 return super(lfsvfs, self).join(path[0:2], path[2:]) |
53 return super(lfsvfs, self).join(path[0:2], path[2:], *insidef) |
50 |
54 |
51 def walk(self, path=None, onerror=None): |
55 def walk(self, path=None, onerror=None): |
52 """Yield (dirpath, [], oids) tuple for blobs under path |
56 """Yield (dirpath, [], oids) tuple for blobs under path |
53 |
57 |
54 Oids only exist in the root of this vfs, so dirpath is always ''. |
58 Oids only exist in the root of this vfs, so dirpath is always ''. |
75 |
79 |
76 class nullvfs(lfsvfs): |
80 class nullvfs(lfsvfs): |
77 def __init__(self): |
81 def __init__(self): |
78 pass |
82 pass |
79 |
83 |
80 def exists(self, oid): |
84 def exists(self, path: Optional[bytes] = None) -> bool: |
81 return False |
85 return False |
82 |
86 |
83 def read(self, oid): |
87 def read(self, oid): |
84 # store.read() calls into here if the blob doesn't exist in its |
88 # store.read() calls into here if the blob doesn't exist in its |
85 # self.vfs. Raise the same error as a normal vfs when asked to read a |
89 # self.vfs. Raise the same error as a normal vfs when asked to read a |
91 ) |
95 ) |
92 |
96 |
93 def walk(self, path=None, onerror=None): |
97 def walk(self, path=None, onerror=None): |
94 return (b'', [], []) |
98 return (b'', [], []) |
95 |
99 |
96 def write(self, oid, data): |
100 def write(self, *args, **kwargs) -> int: |
97 pass |
101 return 0 |
98 |
102 |
99 |
103 |
100 class lfsuploadfile(httpconnectionmod.httpsendfile): |
104 class lfsuploadfile(httpconnectionmod.httpsendfile): |
101 """a file-like object that supports keepalive.""" |
105 """a file-like object that supports keepalive.""" |
102 |
106 |