Log lar temizlendi

This commit is contained in:
2025-10-29 11:59:04 +03:00
parent f6d9c64bcc
commit f5ac5a1c6c
2 changed files with 1 additions and 17 deletions

View File

@@ -2086,7 +2086,6 @@ function broadcastFileUpdate(rootFolder) {
function broadcastDiskSpace() { function broadcastDiskSpace() {
if (!wss) return; if (!wss) return;
getSystemDiskInfo(DOWNLOAD_DIR).then(diskInfo => { getSystemDiskInfo(DOWNLOAD_DIR).then(diskInfo => {
console.log("🔄 Broadcasting disk space:", diskInfo);
const data = JSON.stringify({ const data = JSON.stringify({
type: "diskSpace", type: "diskSpace",
data: diskInfo data: diskInfo
@@ -3522,15 +3521,10 @@ const server = app.listen(PORT, () =>
wss = new WebSocketServer({ server }); wss = new WebSocketServer({ server });
wss.on("connection", (ws) => { wss.on("connection", (ws) => {
console.log("🔌 New WebSocket connection established");
ws.send(JSON.stringify({ type: "progress", torrents: snapshot() })); ws.send(JSON.stringify({ type: "progress", torrents: snapshot() }));
// Bağlantı kurulduğunda disk space bilgisi gönder // Bağlantı kurulduğunda disk space bilgisi gönder
broadcastDiskSpace(); broadcastDiskSpace();
ws.on("close", () => {
console.log("🔌 WebSocket connection closed");
});
ws.on("error", (error) => { ws.on("error", (error) => {
console.error("🔌 WebSocket error:", error); console.error("🔌 WebSocket error:", error);
}); });

View File

@@ -10,20 +10,17 @@ const execAsync = promisify(exec);
* @returns {Promise<Object>} Disk alanı bilgileri * @returns {Promise<Object>} Disk alanı bilgileri
*/ */
export async function getDiskSpace(path = '/') { export async function getDiskSpace(path = '/') {
console.log("🔍 Getting disk space for path:", path);
try { try {
// Linux/macOS için df komutu kullan // Linux/macOS için df komutu kullan
if (process.platform !== 'win32') { if (process.platform !== 'win32') {
const escapedPath = path.replace(/(["\\$`])/g, '\\$1'); const escapedPath = path.replace(/(["\\$`])/g, '\\$1');
const blockFlag = process.platform === 'darwin' ? '-k' : '-k'; const blockFlag = process.platform === 'darwin' ? '-k' : '-k';
const { stdout } = await execAsync(`df ${blockFlag} "${escapedPath}"`); const { stdout } = await execAsync(`df ${blockFlag} "${escapedPath}"`);
console.log("📊 df command output:", stdout);
const lines = stdout.trim().split('\n'); const lines = stdout.trim().split('\n');
if (lines.length >= 2) { if (lines.length >= 2) {
// Çoğu dağıtımda veriler ikinci satırda // Çoğu dağıtımda veriler ikinci satırda
const data = lines[lines.length - 1].trim().split(/\s+/); const data = lines[lines.length - 1].trim().split(/\s+/);
console.log("📋 Parsed df data:", data);
if (data.length < 5) { if (data.length < 5) {
throw new Error("df output could not be parsed"); throw new Error("df output could not be parsed");
} }
@@ -38,7 +35,6 @@ export async function getDiskSpace(path = '/') {
const used = usedBlocks * 1024; const used = usedBlocks * 1024;
const available = availableBlocks * 1024; const available = availableBlocks * 1024;
console.log("📏 Calculated sizes (bytes):", { total, used, available, usedPercent });
const totalFormatted = formatBytes(total); const totalFormatted = formatBytes(total);
const usedFormatted = formatBytes(used); const usedFormatted = formatBytes(used);
@@ -62,7 +58,6 @@ export async function getDiskSpace(path = '/') {
usedUnit: usedFormatted.unit usedUnit: usedFormatted.unit
}; };
console.log("✅ Final disk space result:", result);
return result; return result;
} }
} else { } else {
@@ -158,7 +153,6 @@ function parseSize(sizeStr) {
const unit = match[2] ? match[2].toUpperCase() : ''; const unit = match[2] ? match[2].toUpperCase() : '';
const result = value * (units[unit] || 1); const result = value * (units[unit] || 1);
console.log(`🔍 parseSize: ${sizeStr} -> ${result} bytes`);
return result; return result;
} }
@@ -228,13 +222,9 @@ export async function getDownloadsSize(downloadsPath) {
* @returns {Promise<Object>} Kapsamlı disk bilgileri * @returns {Promise<Object>} Kapsamlı disk bilgileri
*/ */
export async function getSystemDiskInfo(downloadsPath) { export async function getSystemDiskInfo(downloadsPath) {
console.log("🔍 Getting system disk info for:", downloadsPath);
const diskSpace = await getDiskSpace(downloadsPath); const diskSpace = await getDiskSpace(downloadsPath);
const downloadsSize = await getDownloadsSize(downloadsPath); const downloadsSize = await getDownloadsSize(downloadsPath);
console.log("📊 Disk space result:", diskSpace);
console.log("📁 Downloads size result:", downloadsSize);
return { return {
...diskSpace, ...diskSpace,
downloads: downloadsSize, downloads: downloadsSize,