Skip to content

Commit

Permalink
fpsync: Avoid returning "" from total_*_count() when run.meta file do…
Browse files Browse the repository at this point in the history
…es not exist

Dot ('.') command aborts if sourced file is missing, see:
  https://pubs.opengroup.org/onlinepubs/009695299/utilities/dot.html
making those functions return an empty "" value.

Add a simple check to avoid that situation.
  • Loading branch information
martymac committed Nov 11, 2023
1 parent f4611fe commit a74f1c9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/fpsync
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,8 @@ job_queue_sl_stop () {
total_jobs_count () {
(
total_num_parts=0 ; \
. "${FPART_PARTSDIR}/run.meta" 2>/dev/null ; \
[ -f "${FPART_PARTSDIR}/run.meta" ] && \
. "${FPART_PARTSDIR}/run.meta" 2>/dev/null ; \
echo "${total_num_parts}"
)
}
Expand All @@ -911,7 +912,8 @@ total_jobs_count () {
total_files_count () {
(
total_num_files=0 ; \
. "${FPART_PARTSDIR}/run.meta" 2>/dev/null ; \
[ -f "${FPART_PARTSDIR}/run.meta" ] && \
. "${FPART_PARTSDIR}/run.meta" 2>/dev/null ; \
echo "${total_num_files}"
)
}
Expand All @@ -920,7 +922,8 @@ total_files_count () {
total_size_count () {
(
total_size=0 ; \
. "${FPART_PARTSDIR}/run.meta" 2>/dev/null ; \
[ -f "${FPART_PARTSDIR}/run.meta" ] && \
. "${FPART_PARTSDIR}/run.meta" 2>/dev/null ; \
echo "${total_size}"
)
}
Expand Down

0 comments on commit a74f1c9

Please sign in to comment.