Skip to content

Commit

Permalink
optimize cat -> rm into mv when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
rhelmot committed Jul 14, 2024
1 parent 021591a commit 515b584
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pydatatask/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ def mk_http_get(
sleep $RETRY_DELAY
done
rm $ERR_FILENAME
cat $FILENAME >"{filename}"
rm $FILENAME
mv $FILENAME "{filename}" || cat $FILENAME >"{filename}" && rm -f $FILENAME
"""
else:
raise TypeError(self.os)
Expand Down Expand Up @@ -114,7 +113,7 @@ def mk_http_post(
{'ANY_UPLOADS_FAILED=1' if required_for_success else ''}
fi
rm $ERR_FILENAME
{f'cat $OUTPUT_FILENAME >"{output_filename}"; rm $OUTPUT_FILENAME' if output_filename else ''}
{f'mv $OUTPUT_FILENAME "{output_filename}" || cat $OUTPUT_FILENAME >"{output_filename}" && rm -f $OUTPUT_FILENAME' if output_filename else ''}
"""
else:
raise TypeError(self.os)
Expand Down

0 comments on commit 515b584

Please sign in to comment.