Skip to content

Commit

Permalink
update watch mech
Browse files Browse the repository at this point in the history
  • Loading branch information
yujingz committed Aug 19, 2024
1 parent 13713cf commit f33dc9f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/watch-and-upload/watch-and-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ process_file() {
record_id=$(get_current_record_id)

if cocli record upload "$record_id" "$file"; then
sed -i "\|${file//\//\\/}|d" "$UPLOAD_LOGS"
echo "$(date +'%Y-%m-%d %H:%M:%S')|$file|$md5sum" >>"$UPLOAD_LOGS"
echo "已上传: $file"
else
Expand All @@ -115,7 +116,10 @@ main() {
initialize

echo "开始监控目录: $WATCH_DIR"
fswatch -0 -r -e "(/|^)\.[^/]*$" "$WATCH_DIR" | while read -d "" file; do
fswatch --event "Created" --event "Updated" --event "MovedTo" -0 -r \
-e "(/|^)\.[^/]*$" \
"$WATCH_DIR" | while read -d "" file; do
# echo $file
if [ -f "$file" ] && [[ "$(basename "$file")" != .* ]]; then
echo "正在处理 $file"
process_file "$file"
Expand Down

0 comments on commit f33dc9f

Please sign in to comment.