Skip to content

Commit e32d48b

Browse files
Panaetiusjsam
authored andcommitted
fix: Removes unneccesary call to git lfs with no paths (#658)
* Removes unneccesary call to git lfs with no paths * Catches KeyboardInterrupt and OSError, changes list empty check
1 parent 90e1c48 commit e32d48b

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

renku/api/storage.py

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from subprocess import PIPE, STDOUT, call, run
2424

2525
import attr
26+
from click import BadParameter
2627
from werkzeug.utils import cached_property
2728

2829
from renku import errors
@@ -96,12 +97,15 @@ def has_external_storage(self):
9697

9798
def init_external_storage(self, force=False):
9899
"""Initialize the external storage for data."""
99-
call(
100-
self._CMD_STORAGE_INSTALL + (['--force'] if force else []),
101-
stdout=PIPE,
102-
stderr=STDOUT,
103-
cwd=str(self.path.absolute()),
104-
)
100+
try:
101+
call(
102+
self._CMD_STORAGE_INSTALL + (['--force'] if force else []),
103+
stdout=PIPE,
104+
stderr=STDOUT,
105+
cwd=str(self.path.absolute()),
106+
)
107+
except (KeyboardInterrupt, OSError) as e:
108+
raise BadParameter('Couldn\'t run \'git lfs\':\n{0}'.format(e))
105109

106110
def init_repository(self, name=None, force=False):
107111
"""Initialize a local Renku repository."""
@@ -132,22 +136,29 @@ def track_paths_in_storage(self, *paths):
132136
# TODO create configurable filter and follow .gitattributes
133137
track_paths.append(str(path))
134138

135-
call(
136-
self._CMD_STORAGE_TRACK + track_paths,
137-
stdout=PIPE,
138-
stderr=STDOUT,
139-
cwd=str(self.path),
140-
)
139+
if track_paths:
140+
try:
141+
call(
142+
self._CMD_STORAGE_TRACK + track_paths,
143+
stdout=PIPE,
144+
stderr=STDOUT,
145+
cwd=str(self.path),
146+
)
147+
except (KeyboardInterrupt, OSError) as e:
148+
raise BadParameter('Couldn\'t run \'git lfs\':\n{0}'.format(e))
141149

142150
@ensure_external_storage
143151
def untrack_paths_from_storage(self, *paths):
144152
"""Untrack paths from the external storage."""
145-
call(
146-
self._CMD_STORAGE_UNTRACK + list(paths),
147-
stdout=PIPE,
148-
stderr=STDOUT,
149-
cwd=str(self.path),
150-
)
153+
try:
154+
call(
155+
self._CMD_STORAGE_UNTRACK + list(paths),
156+
stdout=PIPE,
157+
stderr=STDOUT,
158+
cwd=str(self.path),
159+
)
160+
except (KeyboardInterrupt, OSError) as e:
161+
raise BadParameter('Couldn\'t run \'git lfs\':\n{0}'.format(e))
151162

152163
@ensure_external_storage
153164
def pull_paths_from_storage(self, *paths):

0 commit comments

Comments
 (0)