Skip to content

Commit

Permalink
dulwich: fix DulwichObject
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed May 31, 2022
1 parent 6e62792 commit 28973b1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scmrepo/git/backend/dulwich/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def open(self, mode: str = "r", encoding: str = None):
# NOTE: we didn't load the object before as Dulwich will also try to
# load the contents of it into memory, which will slow down Trie
# building considerably.
obj = self.repo[self.sha]
obj = self.repo[self._sha]
data = obj.as_raw_string()
if mode == "rb":
return BytesIO(data)
Expand All @@ -72,19 +72,22 @@ def mode(self) -> int:
return self._mode

def scandir(self) -> Iterable["DulwichObject"]:
tree = self.repo[self.sha]
tree = self.repo[self._sha]
for entry in tree.iteritems(): # noqa: B301
yield DulwichObject(
self.repo, entry.path.decode(), entry.mode, entry.sha
)

@cached_property
def size(self) -> int: # pylint: disable=invalid-overridden-method
return len(self.repo[self.sha].as_raw_string())
try:
return self.repo[self._sha].raw_length()
except KeyError:
return 0

@property
def sha(self) -> str:
return self._sha
return self._sha.decode("ascii")


class DulwichProgressReporter(GitProgressReporter):
Expand Down

0 comments on commit 28973b1

Please sign in to comment.