Check if there is a need to update the Dangerzone container image, taking into account the user preference, the installed container images and the released container images if updates are enabled.
()
| 55 | |
| 56 | |
| 57 | def get_installation_strategy() -> Strategy: |
| 58 | """ |
| 59 | Check if there is a need to update the Dangerzone container image, |
| 60 | taking into account the user preference, the installed container images |
| 61 | and the released container images if updates are enabled. |
| 62 | """ |
| 63 | # This logic compares the following indexes to make a decision: |
| 64 | # |
| 65 | # local_log_index: |
| 66 | # |
| 67 | # The largest log index of any installed container image. |
| 68 | # |
| 69 | # If an image is not present or this information is missing, |
| 70 | # treat it as 0, meaning that a container image needs to be installed |
| 71 | # either locally or remotely. |
| 72 | # |
| 73 | # Because it's read from the signatures, it can be greater than |
| 74 | # the log index of the actual installed image, in case of application |
| 75 | # downgrades (e.g. from 0.11.0 to 0.10.0). |
| 76 | # |
| 77 | # remote_log_index: |
| 78 | # |
| 79 | # The largest log index for remote updates. |
| 80 | # |
| 81 | # This log index and the corresponding signatures have been verified |
| 82 | # by the application before. |
| 83 | # |
| 84 | # If updates are disabled, or errors occured while attempting to detect |
| 85 | # updates, it is treated as 0 for this run, meaning that we should not |
| 86 | # install images remotely. |
| 87 | # |
| 88 | # If the update checker cannot run right away, it will use the latest |
| 89 | # value that it has observed. |
| 90 | # |
| 91 | # bundled_log_index: |
| 92 | # |
| 93 | # The log index of the image bundled with dangerzone. |
| 94 | # It remains the same during the lifetime of a released Dangerzone |
| 95 | # version. |
| 96 | # |
| 97 | # If no container.tar is bundled (i.e., the dangerzone package), this is |
| 98 | # set to 0 so that the installer falls back to remote installation. |
| 99 | # |
| 100 | # max_log_index: |
| 101 | # |
| 102 | # The target log index for this run, calculated as |
| 103 | # the max of all the above indexes. |
| 104 | |
| 105 | bundled_log_index = LAST_KNOWN_LOG_INDEX if is_container_tar_bundled() else 0 |
| 106 | |
| 107 | podman_images = runtime.list_image_digests() |
| 108 | settings = Settings() |
| 109 | |
| 110 | # Compute the local log index |
| 111 | if not podman_images or not LAST_LOG_INDEX.exists(): |
| 112 | log.debug("No podman images or no last_log_index file") |
| 113 | local_log_index = 0 |
| 114 | else: |