Skip to content

Commit 917ca3a

Browse files
authored
Merge pull request #208 from cpcloud/close-files-in-pin-download
2 parents a4aecfc + 0992978 commit 917ca3a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pins/boards.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,17 +388,16 @@ def pin_download(self, name, version=None, hash=None) -> Sequence[str]:
388388

389389
# TODO: raise for multiple files
390390
# fetch file
391-
f = load_file(
391+
with load_file(
392392
meta, self.fs, self.construct_path([pin_name, meta.version.version])
393-
)
393+
) as f:
394+
# could also check whether f isinstance of PinCache
395+
fname = getattr(f, "name", None)
394396

395-
# could also check whether f isinstance of PinCache
396-
fname = getattr(f, "name", None)
397+
if fname is None:
398+
raise PinsError("pin_download requires a cache.")
397399

398-
if fname is None:
399-
raise PinsError("pin_download requires a cache.")
400-
401-
return [str(Path(fname).absolute())]
400+
return [str(Path(fname).absolute())]
402401

403402
def pin_upload(
404403
self,

0 commit comments

Comments
 (0)