Skip to content

Commit

Permalink
Call mark_event_incomplete when validate_download fails
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolemah99 committed Jun 28, 2024
1 parent 392494d commit 32c9de1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
7 changes: 1 addition & 6 deletions cli_meter/meters/sel735/cleanup_incomplete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ log "Starting cleanup process in directory: $base_directory"

# Find and delete all directories matching the pattern *.incomplete_<digit>
find "$base_directory" -type d -regex '.*/.*\.incomplete_[0-9]+' -print0 | while IFS= read -r -d '' dir; do
rm -rf "$dir"
if [ ! -d "$dir" ]; then
log "Successfully deleted $dir"
else
log "Failed to delete $dir"
fi
rm -rf "$dir" && log "Successfully deleted $dir" || log "Failed to delete $dir"
done

echo "Cleanup process completed."
11 changes: 4 additions & 7 deletions cli_meter/meters/sel735/commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ handle_sigint() {
else
log "current_event_id is not set, no event to move to .incomplete."
fi

source "$current_dir/cleanup_incomplete.sh" "$base_output_dir"
}

Expand All @@ -35,11 +35,10 @@ mark_event_incomplete() {

# Check if the original directory exists
if [ -d "$original_dir" ]; then
# Find an available suffix or the one to rotate
local suffix=1
while [ -d "${base_incomplete_dir}_${suffix}" ]; do
let suffix++
# If reaching the 6th iteration, start rotation from 1
((suffix++))
# If we reach 5, we need to rotate the directories
if [ "$suffix" -gt 5 ]; then
suffix=5
break
Expand Down Expand Up @@ -71,9 +70,7 @@ validate_download() {
# Files expect to have downloaded
local expected_files=("CEV_${event_id}.CEV" "HR_${event_id}.CFG" "HR_${event_id}.DAT" "HR_${event_id}.HDR" "HR_${event_id}.ZDAT")
for file in "${expected_files[@]}"; do
if [ ! -f "${event_dir}/${file}" ]; then
return 0 # File is missing
fi
[ ! -f "${event_dir}/${file}" ] && return 0 # File is missing
done
return 1 # All files are present
}
2 changes: 1 addition & 1 deletion cli_meter/meters/sel735/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ for event_info in $($current_dir/get_events.sh "$meter_ip" "$meter_id" "$base_ou
else
#TODO: handle this case
log "Not all files downloaded for event: $event_id"
#mark_event_incomplete "$event_id" "$output_dir"
mark_event_incomplete "$event_id" "$output_dir"
fi
else
log "Download failed for event_id: $event_id, skipping metadata creation."
Expand Down

0 comments on commit 32c9de1

Please sign in to comment.