Skip to content

Commit 183f246

Browse files
committed
cleanup
1 parent da3ef41 commit 183f246

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

Diff for: makefile

+33-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,37 @@
1-
MACOS_TARGET = x86_64-apple-darwin
1+
# Project Variables
2+
BIN_NAME = redis-file-monitor
3+
BUILD_DIR = target
4+
TARGET_DIR = $(BUILD_DIR)/release
25

3-
all: build-macos
6+
# Build a release binary
7+
build:
8+
cargo build --release
49

5-
build-macos:
6-
cargo build --release --target $(MACOS_TARGET)
10+
# Strip unneeded symbols to reduce size (Linux/macOS)
11+
strip:
12+
strip $(TARGET_DIR)/$(BIN_NAME) || echo "Skipping strip (unsupported on this OS)"
713

14+
# Compress the binary using UPX (optional, requires UPX installed)
15+
compress: build
16+
upx --best --lzma $(TARGET_DIR)/$(BIN_NAME) || echo "UPX compression failed or not installed"
17+
18+
# Package the binary into a .tar.gz archive (Linux/macOS)
19+
package: build strip
20+
tar -czvf $(BIN_NAME).tar.gz -C $(TARGET_DIR) $(BIN_NAME)
21+
22+
# Package the binary into a .zip archive (Windows)
23+
package-win: build strip
24+
zip -j $(BIN_NAME).zip $(TARGET_DIR)/$(BIN_NAME).exe
25+
26+
# Clean up build artifacts
827
clean:
9-
cargo clean
28+
cargo clean
29+
rm -f $(BIN_NAME).tar.gz $(BIN_NAME).zip
30+
31+
# Run the program
32+
run:
33+
cargo run --release -- --watch-dir . --redis-cli redis-cli
34+
35+
# Test the project
36+
test:
37+
cargo test

Diff for: src/main.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::path::{Path, PathBuf};
66
use std::process::Command;
77
use tokio::runtime::Runtime;
88
use tracing::{error, info, warn};
9-
use tracing_subscriber;
109

1110
/// CLI Arguments
1211
#[derive(Parser, Debug)]
@@ -77,7 +76,7 @@ async fn watch_directory(dir: &Path, redis_cli: &str) -> Result<()> {
7776
/// Processes file events
7877
async fn process_events(rx: &mut tokio::sync::mpsc::Receiver<Event>, redis_cli: &str) {
7978
while let Some(event) = rx.recv().await {
80-
if let Some(path) = event.paths.get(0) {
79+
if let Some(path) = event.paths.first() {
8180
if let EventKind::Modify(notify::event::ModifyKind::Data(
8281
notify::event::DataChange::Content,
8382
)) = event.kind

0 commit comments

Comments
 (0)