From fb67c60a849943fdf4330124ed01a0e966f0b8f5 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Thu, 16 May 2019 17:28:41 +0530 Subject: [PATCH] backups: Avoid creating duplicate SSH remotes Signed-off-by: Joseph Nuthalapati --- plinth/modules/backups/forms.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plinth/modules/backups/forms.py b/plinth/modules/backups/forms.py index 032c8e897..2ac85a281 100644 --- a/plinth/modules/backups/forms.py +++ b/plinth/modules/backups/forms.py @@ -154,7 +154,12 @@ class AddRepositoryForm(forms.Form): path = cleaned_data.get("repository") credentials = self.get_credentials() - # Validate remote + # Avoid creation of duplicate ssh remotes + for storage in network_storage.get_storages().values(): + if storage['path'] == path: + raise forms.ValidationError( + _('Remote backup repository already exists.')) + user_at_host, dir_path = path.split(':') username, hostname = user_at_host.split('@') dir_path = dir_path.replace('~', f'/home/{username}')