import readline from "readline"; const user = process.argv[2]; // Estensioni foto/video const photoExt = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".tiff", ".heic", ".heif"]; const videoExt = [".mp4", ".mov", ".avi", ".mkv", ".webm", ".m4v"]; function isMediaFile(filename) { const lower = filename.toLowerCase(); return photoExt.some(ext => lower.endsWith(ext)) || videoExt.some(ext => lower.endsWith(ext)); } console.log(`Node attivo per utente: ${user}`); const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity }); rl.on("line", line => { const parts = line.trim().split(/\s+/); const path = parts[0]; const action = parts[1]; const file = parts[2]; if (!file) return; const isDir = action.includes("ISDIR"); // ๐Ÿ”ฅ Se รจ directory โ†’ NON controllare mediafile if (!isDir && !isMediaFile(file)) { console.log(`Ignorato (non media): ${file}`); return; } let type = null; // // ๐Ÿ”ต DIRECTORY EVENTS // // ADD_DIR โ†’ MOVED_TO,ISDIR if (action === "MOVED_TO,ISDIR") { type = "ADD_DIR"; } // DEL_DIR โ†’ MOVED_FROM,ISDIR else if (action === "MOVED_FROM,ISDIR") { type = "DEL_DIR"; } // // ๐Ÿ”ต FILE EVENTS // // ADD โ†’ CLOSE_WRITE o CLOSE_WRITE,CLOSE else if (/^CLOSE_WRITE(,CLOSE)?$/.test(action)) { type = "ADD"; } // ADD โ†’ MOVED_TO else if (action === "MOVED_TO") { type = "ADD"; } // DEL โ†’ MOVED_FROM else if (action === "MOVED_FROM") { type = "DEL"; } // DEL โ†’ DELETE else if (action === "DELETE") { type = "DEL"; } else { return; } console.log(`${type} ${file} ${path} ${user}`); });