Skip to content

Commit e046b3a

Browse files
authored
fix(service): remove project cache directory before clone (#3195)
1 parent 5fbc8d2 commit e046b3a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

renku/ui/service/controllers/utils/project_clone.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# See the License for the specific language governing permissions and
1717
# limitations under the License.
1818
"""Utilities for renku service controllers."""
19+
import shutil
20+
1921
from renku.command.clone import project_clone_command
2022
from renku.core.util.contexts import renku_project_context
2123
from renku.ui.service.cache.models.project import Project
@@ -31,7 +33,9 @@ def user_project_clone(cache, user_data, project_data):
3133

3234
user = cache.ensure_user(user_data)
3335
project = cache.make_project(user, project_data, persist=False)
34-
project.abs_path.mkdir(parents=True, exist_ok=True)
36+
37+
# NOTE: Create parent dir so lock file can be created.
38+
project.abs_path.parent.mkdir(parents=True, exist_ok=True)
3539

3640
with project.write_lock(), renku_project_context(project.abs_path, check_git_path=False):
3741
git_url = project_data.get("git_url")
@@ -51,6 +55,12 @@ def user_project_clone(cache, user_data, project_data):
5155
service_log.debug(f"project already cloned, skipping clone: {git_url}")
5256
return found_project
5357

58+
if project.abs_path.exists():
59+
# NOTE: Remove dir since a previous clone might have failed somewhere in the middle.
60+
shutil.rmtree(str(project.abs_path))
61+
62+
project.abs_path.mkdir(parents=True, exist_ok=True)
63+
5464
repo, project.initialized = (
5565
project_clone_command()
5666
.build()

0 commit comments

Comments
 (0)