Skip to content

Commit

Permalink
image: ek-content-list: Sort and dedup channel list
Browse files Browse the repository at this point in the history
This will avoid trying to download and install the same channel more
than once.

#117
  • Loading branch information
jprvita committed Oct 2, 2023
1 parent 54e3409 commit 7e466dc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hooks/image/51-ek-content-list
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ fi
# hooks/image/53-ek-content-preload
EK_CHANNELS_FILE="${EIB_TMPDIR}"/ek-channels

rm -f "${EK_CHANNELS_FILE}"
rm -f "${EK_CHANNELS_FILE}" "${EK_CHANNELS_FILE}.tmp"
collections="${OSTREE_VAR}"/lib/flatpak/app/org.endlessos.Key/current/active/files/share/endless-key/collections/*.json
for collection in ${collections}; do
# Check if the file basename stripped off of -0001.json is part of the list
# of collections to be installed.
bn=$(basename ${collection})
if [[ "${EIB_ENDLESSKEY_COLLECTIONS}" =~ .*"${bn%-????.json}".* ]] ; then
jq -r '.channels[].id' "${collection}" >> "${EK_CHANNELS_FILE}"
jq -r '.channels[].id' "${collection}" >> "${EK_CHANNELS_FILE}.tmp"
fi
done
if [ -f "${EK_CHANNELS_FILE}.tmp" ]; then
sort -u "${EK_CHANNELS_FILE}.tmp" > "${EK_CHANNELS_FILE}"
fi

0 comments on commit 7e466dc

Please sign in to comment.