From c7b960edfa4ae9a7c55bb23cd5dd6f15ce5a6096 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 21 Jul 2020 10:40:09 +0200 Subject: [PATCH] Don't send -1 as profile count The server gives an error about this and we got complaints about it. As far as we know this can only happen when users mess with their profile folders. Still, it's good to not send -1. The original implementation of this is indeed very naive, but we don't have the resources to refactor that now. --- cura/Backups/Backup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cura/Backups/Backup.py b/cura/Backups/Backup.py index 61f1aa686c..011eb97310 100644 --- a/cura/Backups/Backup.py +++ b/cura/Backups/Backup.py @@ -64,9 +64,9 @@ class Backup: files = archive.namelist() # Count the metadata items. We do this in a rather naive way at the moment. - machine_count = len([s for s in files if "machine_instances/" in s]) - 1 - material_count = len([s for s in files if "materials/" in s]) - 1 - profile_count = len([s for s in files if "quality_changes/" in s]) - 1 + machine_count = max(len([s for s in files if "machine_instances/" in s]) - 1, 0) # If people delete their profiles but not their preferences, it can still make a backup, and report -1 profiles. Server crashes on this. + material_count = max(len([s for s in files if "materials/" in s]) - 1, 0) + profile_count = max(len([s for s in files if "quality_changes/" in s]) - 1, 0) plugin_count = len([s for s in files if "plugin.json" in s]) # Store the archive and metadata so the BackupManager can fetch them when needed.