querysub 0.248.0 → 0.249.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.248.0",
3
+ "version": "0.249.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -105,10 +105,12 @@ PIPE_FILE="$1"
105
105
 
106
106
  # Initialize position tracking
107
107
  CURRENT_POS=0
108
+ LAST_MTIME=""
108
109
 
109
110
  # Read initial content and get file size
110
111
  if [ -f "$PIPE_FILE" ]; then
111
112
  CURRENT_SIZE=$(stat -c%s "$PIPE_FILE" 2>/dev/null || wc -c < "$PIPE_FILE")
113
+ LAST_MTIME=$(stat -c%Y "$PIPE_FILE" 2>/dev/null || stat -f%m "$PIPE_FILE" 2>/dev/null || echo "0")
112
114
  # Output initial content like tail would
113
115
  if [ $CURRENT_SIZE -gt 0 ]; then
114
116
  cat "$PIPE_FILE"
@@ -118,26 +120,34 @@ else
118
120
  CURRENT_SIZE=0
119
121
  fi
120
122
 
121
- # Watch for file changes
122
- while inotifywait -q -e modify "$PIPE_FILE" 2>/dev/null; do
123
+ # Poll for file changes every 250ms
124
+ while true; do
125
+ sleep 0.25
126
+
123
127
  if [ -f "$PIPE_FILE" ]; then
124
- NEW_SIZE=$(stat -c%s "$PIPE_FILE" 2>/dev/null || wc -c < "$PIPE_FILE")
128
+ NEW_MTIME=$(stat -c%Y "$PIPE_FILE" 2>/dev/null || stat -f%m "$PIPE_FILE" 2>/dev/null || echo "0")
125
129
 
126
- if [ $NEW_SIZE -lt $CURRENT_SIZE ]; then
127
- # File has shrunk (truncated), reset position to end of file
128
- # Don't output anything, just reset our tracking
129
- CURRENT_POS=$NEW_SIZE
130
- CURRENT_SIZE=$NEW_SIZE
131
- elif [ $NEW_SIZE -gt $CURRENT_SIZE ]; then
132
- # File grew normally, read only the new part
133
- if [ $CURRENT_POS -lt $NEW_SIZE ]; then
134
- # Use tail with byte offset to read from current position
135
- tail -c +$((CURRENT_POS + 1)) "$PIPE_FILE" | head -c $((NEW_SIZE - CURRENT_POS))
130
+ # Check if file was modified
131
+ if [ "$NEW_MTIME" != "$LAST_MTIME" ]; then
132
+ NEW_SIZE=$(stat -c%s "$PIPE_FILE" 2>/dev/null || wc -c < "$PIPE_FILE")
133
+
134
+ if [ $NEW_SIZE -lt $CURRENT_SIZE ]; then
135
+ # File has shrunk (truncated), reset position to end of file
136
+ # Don't output anything, just reset our tracking
136
137
  CURRENT_POS=$NEW_SIZE
138
+ CURRENT_SIZE=$NEW_SIZE
139
+ elif [ $NEW_SIZE -gt $CURRENT_SIZE ]; then
140
+ # File grew normally, read only the new part
141
+ if [ $CURRENT_POS -lt $NEW_SIZE ]; then
142
+ # Use tail with byte offset to read from current position
143
+ tail -c +$((CURRENT_POS + 1)) "$PIPE_FILE" | head -c $((NEW_SIZE - CURRENT_POS))
144
+ CURRENT_POS=$NEW_SIZE
145
+ fi
146
+ CURRENT_SIZE=$NEW_SIZE
137
147
  fi
138
- CURRENT_SIZE=$NEW_SIZE
148
+
149
+ LAST_MTIME="$NEW_MTIME"
139
150
  fi
140
- # If sizes are equal, no change to output
141
151
  fi
142
152
  done`);
143
153