Skip to content

Commit

Permalink
fix: linux path
Browse files Browse the repository at this point in the history
  • Loading branch information
trueai-org committed Dec 26, 2023
1 parent adda72b commit 4573ed2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/MDriveSync.Core/Services/Job.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Data;
using System.Diagnostics;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json;
Expand Down Expand Up @@ -385,21 +386,35 @@ private void Initialize()
var sw = new Stopwatch();
sw.Start();

var isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);

// 格式化路径
_localRestorePath = _jobConfig.Restore.TrimPath();
if (isLinux && !string.IsNullOrWhiteSpace(_localRestorePath))
{
_localRestorePath = $"/{_localRestorePath}";
}

_driveSavePath = _jobConfig.Target.TrimPrefix();

// 格式化备份目录
var sources = _jobConfig.Sources.Where(c => !string.IsNullOrWhiteSpace(c)).Select(c => c.TrimPath()).Distinct().ToList();
_jobConfig.Sources.Clear();
foreach (var item in sources)
{
var dir = new DirectoryInfo(item);
var path = item.TrimPath();
if (isLinux && !string.IsNullOrWhiteSpace(path))
{
path = $"/{path}";
}

var dir = new DirectoryInfo(path);
if (!dir.Exists)
{
dir.Create();
}
_jobConfig.Sources.Add(dir.FullName);

_jobConfig.Sources.Add($"/{dir.FullName.TrimPath()}");
}

_localFileCacheName = Path.Combine(".cache", $"local_files_cache_{_jobConfig.Id}.txt");
Expand Down

0 comments on commit 4573ed2

Please sign in to comment.