added debug logs

This commit is contained in:
Flaminel
2025-02-21 23:32:14 +02:00
parent 19ac8cbd28
commit 029f255351
@@ -117,12 +117,16 @@ public class HardlinkFileService : IHardlinkFileService
try try
{ {
if (Syscall.stat(filePath, out Stat stat) != 0) if (Syscall.stat(filePath, out Stat stat) != 0)
{
_logger.LogDebug("failed to stat file {file}", filePath);
return 0; return 0;
}
if (!ignoreRootDir) if (!ignoreRootDir)
{ {
// Simple case: Just check if >1 hardlink exists // Simple case: Just check if >1 hardlink exists
return stat.st_nlink > 1 ? stat.st_nlink : 0; _logger.LogDebug("stat file {file} | nlink: {nlink}", filePath, stat.st_nlink);
return stat.st_nlink;
} }
// Adjusted case: Subtract links from the ignored directory // Adjusted case: Subtract links from the ignored directory
@@ -130,12 +134,14 @@ public class HardlinkFileService : IHardlinkFileService
? count ? count
: 1; // Default to 1 if not found : 1; // Default to 1 if not found
_logger.LogDebug("stat file {file} | nlink: {nlink} | ignored: {ignored}", filePath, stat.st_nlink, linksInIgnoredDir);
long adjustedCount = (long)stat.st_nlink - linksInIgnoredDir; long adjustedCount = (long)stat.st_nlink - linksInIgnoredDir;
return (ulong)Math.Max(adjustedCount, 0); return (ulong)Math.Max(adjustedCount, 0);
} }
catch (Exception exception) catch (Exception exception)
{ {
_logger.LogError(exception, "Failed to stat file {file}", filePath); _logger.LogError(exception, "failed to stat file {file}", filePath);
return 0; return 0;
} }
} }