Skip to content

Commit bc5c8d2

Browse files
committed
FIX: Only consider the file exists if size > 0. Only condider donwload complete if size > 0
1 parent 0e1d068 commit bc5c8d2

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

ardupilot_methodic_configurator/backend_filesystem.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,11 @@ def vehicle_configuration_file_exists(self, filename: str) -> bool:
292292
filename (str): The name of the file to check.
293293
294294
Returns:
295-
bool: True if the file exists and is a file (not a directory), False otherwise.
295+
bool: True if the file exists and is a file (not a directory) and is not empty, False otherwise.
296296
297297
"""
298-
return os_path.exists(os_path.join(self.vehicle_dir, filename)) and os_path.isfile(
299-
os_path.join(self.vehicle_dir, filename)
300-
)
298+
file_path = os_path.join(self.vehicle_dir, filename)
299+
return os_path.exists(file_path) and os_path.isfile(file_path) and os_path.getsize(file_path) > 0
301300

302301
def __all_intermediate_parameter_file_comments(self) -> dict[str, str]:
303302
"""

ardupilot_methodic_configurator/backend_internet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def download_file_from_url(
7676

7777
if progress_callback:
7878
progress_callback(100.0, _("Download complete"))
79-
return True
79+
return bool(downloaded > 0)
8080

8181
except requests_Timeout:
8282
logging_error(_("Download timed out"))

0 commit comments

Comments
 (0)