mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 18:27:24 +01:00
make storage size calculation asynchronous and running in parallel
This commit is contained in:
parent
01e36f64ff
commit
549a93654a
11 changed files with 110 additions and 37 deletions
|
|
@ -62,9 +62,11 @@ public sealed class FileCompactor
|
|||
MassCompactRunning = false;
|
||||
}
|
||||
|
||||
public long GetFileSizeOnDisk(string filePath)
|
||||
public long GetFileSizeOnDisk(string filePath, bool? isNTFS = null)
|
||||
{
|
||||
if (Dalamud.Utility.Util.IsWine()) return new FileInfo(filePath).Length;
|
||||
bool ntfs = isNTFS ?? string.Equals(new DriveInfo(new FileInfo(filePath).Directory!.Root.FullName).DriveFormat, "NTFS", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (Dalamud.Utility.Util.IsWine() || !ntfs) return new FileInfo(filePath).Length;
|
||||
|
||||
var clusterSize = GetClusterSize(filePath);
|
||||
if (clusterSize == -1) return new FileInfo(filePath).Length;
|
||||
|
|
@ -105,6 +107,14 @@ public sealed class FileCompactor
|
|||
|
||||
private void CompactFile(string filePath)
|
||||
{
|
||||
var fs = new DriveInfo(new FileInfo(filePath).Directory!.Root.FullName);
|
||||
bool isNTFS = string.Equals(fs.DriveFormat, "NTFS", StringComparison.OrdinalIgnoreCase);
|
||||
if (!isNTFS)
|
||||
{
|
||||
_logger.LogWarning("Drive for file {file} is not NTFS", filePath);
|
||||
return;
|
||||
}
|
||||
|
||||
var oldSize = new FileInfo(filePath).Length;
|
||||
var clusterSize = GetClusterSize(filePath);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue