Skip to content

Commit

Permalink
fix: linux backup
Browse files Browse the repository at this point in the history
  • Loading branch information
trueai-org committed Jun 18, 2024
1 parent 6ef998a commit d02345e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/MDriveSync.Core/Services/AliyunJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1641,9 +1641,8 @@ private void ClearDownloadCache(string saveRootPath)
private string GetDirectoryKey(string localRootPath, DirectoryInfo directoryInfo)
{
var localRootInfo = new DirectoryInfo(localRootPath);
var rootPathName = localRootInfo.Name;
var subPath = directoryInfo.FullName.TrimPrefix(localRootPath);
return $"{rootPathName}/{subPath}".TrimPath();
var subPath = directoryInfo.FullName.TrimPrefix(localRootInfo.FullName);
return $"{localRootInfo.Name}/{subPath}".TrimPath();
}

/// <summary>
Expand All @@ -1655,9 +1654,8 @@ private string GetDirectoryKey(string localRootPath, DirectoryInfo directoryInfo
private string GetFileKey(string localRootPath, string fileFullPath)
{
var localRootInfo = new DirectoryInfo(localRootPath);
var rootPathName = localRootInfo.Name;
var subPath = fileFullPath.TrimPrefix(localRootInfo.FullName);
return $"{rootPathName}/{subPath}".TrimPath();
return $"{localRootInfo.Name}/{subPath}".TrimPath();
}

/// <summary>
Expand All @@ -1669,9 +1667,11 @@ private string GetFileKey(string localRootPath, string fileFullPath)
private string GetFileKeyPath(string localRootPath, FileInfo fileInfo)
{
var localRootInfo = new DirectoryInfo(localRootPath);
var rootPathName = localRootInfo.Name;
var subPath = Path.GetDirectoryName(fileInfo.FullName).TrimPrefix(localRootInfo.FullName);
return $"{rootPathName}/{subPath}".TrimPath();

// fix: GetDirectoryName none / end
var subPath = Path.GetDirectoryName(fileInfo.FullName).TrimPath()
.TrimPrefix(localRootInfo.FullName.TrimPath());
return $"{localRootInfo.Name}/{subPath}".TrimPath();
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/MDriveSync.Core/Services/LocalStorageJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ void LoadFiles(string dir)
{
IsFile = false,
Hash = string.Empty,
Key = dirInfo.FullName.TrimPath().TrimPrefix(rootInfo.FullName).TrimPath(),
Key = dirInfo.FullName.TrimPrefix(rootInfo.FullName).TrimPath(),
Length = 0,
FullName = dirInfo.FullName,
Name = dirInfo.Name,
Expand All @@ -1333,7 +1333,7 @@ void LoadFiles(string dir)
{
IsFile = true,
Hash = string.Empty,
Key = fileInfo.FullName.TrimPath().TrimPrefix(rootInfo.FullName).TrimPath(),
Key = fileInfo.FullName.TrimPrefix(rootInfo.FullName).TrimPath(),
Length = fileInfo.Length,
FullName = fileInfo.FullName,
CreationTime = fileInfo.CreationTime,
Expand Down Expand Up @@ -2360,7 +2360,7 @@ private void SyncFile(LocalStorageFileInfo localFileInfo)
IsFile = true,
Hash = string.Empty,
Length = targetFileInfo.Length,
Key = targetFileInfo.FullName.TrimPath().TrimPrefix(rootInfo.FullName).TrimPath(),
Key = targetFileInfo.FullName.TrimPrefix(rootInfo.FullName).TrimPath(),
Name = targetFileInfo.Name,

IsExists = targetFileInfo.Exists,
Expand Down

0 comments on commit d02345e

Please sign in to comment.