[fix] Small fixes about file questions in config panel

This commit is contained in:
ljf 2021-09-17 03:15:01 +02:00
parent 63d3ccd827
commit 4a1d6f2257
2 changed files with 8 additions and 5 deletions

View file

@ -123,7 +123,10 @@ _ynh_app_config_apply() {
ynh_print_info --message="File '$bind_file' removed"
else
ynh_backup_if_checksum_is_different --file="$bind_file"
cp "${!short_setting}" "$bind_file"
if [[ "${!short_setting}" != "$bind_file" ]]
then
cp "${!short_setting}" "$bind_file"
fi
ynh_store_file_checksum --file="$bind_file" --update_only
ynh_print_info --message="File '$bind_file' overwrited with ${!short_setting}"
fi

View file

@ -927,11 +927,11 @@ class FileQuestion(Question):
"content": self.value,
"filename": user_answers.get(f"{self.name}[name]", self.name),
}
# If path file are the same
if self.value and str(self.value) == self.current_value:
self.value = None
def _prevalidate(self):
if self.value is None:
self.value = self.current_value
super()._prevalidate()
if (
isinstance(self.value, str)
@ -966,7 +966,7 @@ class FileQuestion(Question):
if not self.value:
return self.value
if Moulinette.interface.type == "api":
if Moulinette.interface.type == "api" and isinstance(self.value, dict):
upload_dir = tempfile.mkdtemp(prefix="tmp_configpanel_")
FileQuestion.upload_dirs += [upload_dir]