ByteSync icon indicating copy to clipboard operation
ByteSync copied to clipboard

[feature] Add IsTransferable helper method to IFileSystemInspector

Open paul-fresquet opened this issue 10 months ago • 0 comments

Summary

Add a convenience method IsTransferable() to IFileSystemInspector that determines whether a filesystem entry can be synchronized. This provides a single, clear API for the most common classification question.

Background

After implementing ClassifyEntry(), callers will often need to check:

var kind = inspector.ClassifyEntry(fileInfo);
if (kind.HasFlag(FileSystemEntryKind.NonTransferable))
{
    // skip
}

A helper method simplifies this common pattern.

Proposed API

public interface IFileSystemInspector
{
    // Existing methods...
    
    /// <summary>
    /// Determines if an entry is a regular file that can be synchronized.
    /// Returns false for symlinks, special files, directories, etc.
    /// </summary>
    bool IsTransferable(FileSystemInfo fsi);
}

Implementation

public bool IsTransferable(FileSystemInfo fsi)
{
    var kind = ClassifyEntry(fsi);
    
    // Only regular files are transferable
    return kind == FileSystemEntryKind.RegularFile;
}

Usage Example

// Before (verbose)
var kind = _inspector.ClassifyEntry(fileInfo);
if (kind != FileSystemEntryKind.RegularFile)
{
    RecordSkippedEntry(...);
    return;
}

// After (concise)
if (!_inspector.IsTransferable(fileInfo))
{
    RecordSkippedEntry(...);
    return;
}

Acceptance Criteria

  • [ ] Add IsTransferable(FileSystemInfo fsi) to IFileSystemInspector
  • [ ] Implement in FileSystemInspector
  • [ ] Returns true only for RegularFile
  • [ ] Returns false for Directory, Symlink, all POSIX special types, Unknown
  • [ ] Unit tests covering all entry kinds
  • [ ] XML documentation

Technical Notes

  • This is a convenience wrapper, not new logic
  • Keeps ClassifyEntry() as the source of truth
  • Consider adding IsTransferableDirectory() if needed for directory sync scenarios

Dependencies

  • Requires: ClassifyEntry() method (issue #263)
  • Requires: FileSystemEntryKind enum (issue #262)

Priority

Nice to Have — Convenience method that improves code readability.

paul-fresquet avatar Feb 01 '26 19:02 paul-fresquet