Skip to content

[refactor] Separate noise filtering from filesystem semantics #264

@paul-fresquet

Description

@paul-fresquet

Summary

Refactor the current file filtering system to clearly separate two distinct concerns:

  1. Filesystem semantics — OS-level file attributes (system flag, offline, etc.) — not user-configurable
  2. Noise filtering — Application-level exclusion of clutter files (.DS_Store, thumbs.db) — user-configurable

Background

Currently, FileSystemInspector.IsSystem() mixes both concerns:

public bool IsSystem(FileInfo fileInfo)
{
    // Noise filtering (application-level)
    var isCommon = fileInfo.Name.In("desktop.ini", "thumbs.db", ".desktop.ini", ".thumbs.db", ".DS_Store");
    
    // Filesystem semantics (OS-level)
    var isSystem = (fileInfo.Attributes & FileAttributes.System) == FileAttributes.System;
    
    return isCommon || isSystem;
}

This conflation makes it hard to:

  • Understand what's being filtered and why
  • Extend the noise file list
  • Allow future user customization of noise filtering

Proposed Design

New Interface Methods

public interface IFileSystemInspector
{
    // Filesystem semantics (non-configurable, OS-level)
    bool HasSystemAttribute(FileInfo fileInfo);  // Windows FileAttributes.System
    bool IsOffline(FileInfo fileInfo);
    bool IsRecallOnDataAccess(FileInfo fileInfo);
    
    // Noise filtering (application-level, potentially configurable)
    bool IsNoiseFile(FileInfo fileInfo);
}

Separate Noise File Detection

Create a dedicated component or static helper for noise file detection:

public static class NoiseFileDetector
{
    private static readonly HashSet<string> KnownNoiseFileNames = new(StringComparer.OrdinalIgnoreCase)
    {
        // Windows
        "desktop.ini",
        "thumbs.db",
        "ehthumbs.db",
        "ehthumbs_vista.db",
        
        // macOS
        ".DS_Store",
        ".AppleDouble",
        ".LSOverride",
        ".Spotlight-V100",
        ".Trashes",
        ".fseventsd",
        ".TemporaryItems",
        ".VolumeIcon.icns",
        
        // Linux
        ".directory"
    };
    
    public static bool IsNoiseFile(string fileName)
    {
        return KnownNoiseFileNames.Contains(fileName);
    }
}

Acceptance Criteria

  • Rename IsSystem() to HasSystemAttribute() (or similar) for clarity
  • Create IsNoiseFile() method with extended file list
  • Update InventoryBuilder to call both methods separately
  • Maintain backward compatibility in SessionSettings.ExcludeSystemFiles behavior
  • Document each noise file and its origin (Windows/macOS/Linux)
  • Unit tests for noise file detection (case sensitivity, all listed files)

Extended Noise File List

File Platform Purpose
desktop.ini Windows Folder customization
thumbs.db Windows Thumbnail cache
ehthumbs.db Windows Media Center thumbnails
ehthumbs_vista.db Windows Vista Media Center
.DS_Store macOS Finder metadata
.AppleDouble macOS Resource forks
.LSOverride macOS Launch Services
.Spotlight-V100 macOS Spotlight index
.Trashes macOS Trash folder
.fseventsd macOS File system events
.TemporaryItems macOS Temporary files
.VolumeIcon.icns macOS Volume icon
.directory Linux (KDE) Folder metadata

Priority

Important — Improves code clarity and prepares for future extensibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions