Add Git overlay, operation tools, and virtualized preview so large folders stay responsive.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
88
src/Explorer.FileOperations/OperationAvailability.cs
Normal file
88
src/Explorer.FileOperations/OperationAvailability.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using Explorer.Domain;
|
||||
using Explorer.Domain.Abstractions;
|
||||
|
||||
namespace Explorer.FileOperations;
|
||||
|
||||
internal static class OperationAvailability
|
||||
{
|
||||
public static bool IsReady(IVolumeService volumes, TransferJob job)
|
||||
{
|
||||
foreach (var path in PathsToCheck(job))
|
||||
{
|
||||
if (!IsVolumeReachable(volumes, path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static IEnumerable<string> PathsToCheck(TransferJob job)
|
||||
{
|
||||
switch (job.Op)
|
||||
{
|
||||
case TransferOp.Delete:
|
||||
if (job.AdditionalSources.Count > 0)
|
||||
{
|
||||
foreach (var src in job.AdditionalSources)
|
||||
{
|
||||
yield return src;
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (var src in job.SourcePath.Split('|', StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
yield return src;
|
||||
}
|
||||
|
||||
yield break;
|
||||
case TransferOp.Copy:
|
||||
case TransferOp.Move:
|
||||
case TransferOp.Rename:
|
||||
case TransferOp.Extract:
|
||||
case TransferOp.Compress:
|
||||
case TransferOp.AddToArchive:
|
||||
if (!string.IsNullOrWhiteSpace(job.DestinationPath))
|
||||
{
|
||||
yield return PathRules.Parent(job.DestinationPath);
|
||||
}
|
||||
|
||||
yield break;
|
||||
case TransferOp.VerifyArchive:
|
||||
yield return job.SourcePath;
|
||||
yield break;
|
||||
case TransferOp.EmptyRecycleBin:
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsVolumeReachable(IVolumeService volumes, string path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (volumes.IsPathReachable(path))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var root = PathRules.VolumeRoot(path);
|
||||
if (string.IsNullOrWhiteSpace(root))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!string.Equals(root, path, StringComparison.OrdinalIgnoreCase) && volumes.IsPathReachable(root))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var slashed = root.EndsWith('\\') ? root : root + "\\";
|
||||
return volumes.IsPathReachable(slashed);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user