Initialize migration. (#88)
Co-authored-by: defnotken <itsdefnotken@gmail.com> Co-authored-by: cake <admin@cakeandbanana.nl> Reviewed-on: #88 Reviewed-by: cake <cake@noreply.git.lightless-sync.org> Co-authored-by: defnotken <defnotken@noreply.git.lightless-sync.org> Co-committed-by: defnotken <defnotken@noreply.git.lightless-sync.org>
This commit was merged in pull request #88.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LightlessSync.Utils
|
||||
@@ -157,7 +156,7 @@ namespace LightlessSync.Utils
|
||||
|
||||
return mountOptions;
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
@@ -234,40 +233,6 @@ namespace LightlessSync.Utils
|
||||
return clusterSize;
|
||||
}
|
||||
|
||||
string realPath = fi.FullName;
|
||||
if (isWine && realPath.StartsWith("Z:\\", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
realPath = "/" + realPath.Substring(3).Replace('\\', '/');
|
||||
}
|
||||
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = "/bin/bash",
|
||||
Arguments = $"-c \"stat -f -c %s '{realPath.Replace("'", "'\\''")}'\"",
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
WorkingDirectory = "/"
|
||||
};
|
||||
|
||||
using var proc = Process.Start(psi);
|
||||
|
||||
string stdout = proc?.StandardOutput.ReadToEnd().Trim() ?? "";
|
||||
string _stderr = proc?.StandardError.ReadToEnd() ?? "";
|
||||
|
||||
try { proc?.WaitForExit(); }
|
||||
catch (Exception ex) { logger?.LogTrace(ex, "stat WaitForExit failed under Wine; ignoring"); }
|
||||
|
||||
if (!(!int.TryParse(stdout, out int block) || block <= 0))
|
||||
{
|
||||
_blockSizeCache[root] = block;
|
||||
logger?.LogTrace("Filesystem block size via stat for {root}: {block}", root, block);
|
||||
return block;
|
||||
}
|
||||
|
||||
logger?.LogTrace("stat did not return valid block size for {file}, output: {out}", fi.FullName, stdout);
|
||||
_blockSizeCache[root] = _defaultBlockSize;
|
||||
return _defaultBlockSize;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user