diff --git a/src/SyncClipboard.Core/Clipboard/Profile/GroupProfile.cs b/src/SyncClipboard.Core/Clipboard/Profile/GroupProfile.cs index b6d40baa..79e30b84 100644 --- a/src/SyncClipboard.Core/Clipboard/Profile/GroupProfile.cs +++ b/src/SyncClipboard.Core/Clipboard/Profile/GroupProfile.cs @@ -46,6 +46,7 @@ private static string CaclHash(string[] files) if (Directory.Exists(file)) { var directoryInfo = new DirectoryInfo(file); + hash += (hash * -1521134295) + directoryInfo.Name.GetHashCode(); foreach (var subFile in directoryInfo.GetFiles("*", SearchOption.AllDirectories)) { sumSize += subFile.Length; @@ -115,7 +116,11 @@ public override async Task BeforeSetLocal(CancellationToken token, IProgress zip.ExtractAll(extractPath, ExtractExistingFileAction.DoNotOverwrite), token).WaitAsync(token); - _files = zip.EntryFileNames.Select(fileName => Path.Combine(extractPath, fileName.TrimEnd('\\', '/'))).ToArray(); + _files = zip.EntryFileNames + .Select(file => file.TrimEnd('/')) + .Where(file => !file.Contains('/')) + .Select(file => Path.Combine(extractPath, file)) + .ToArray(); } protected override ClipboardMetaInfomation CreateMetaInformation() diff --git a/src/SyncClipboard.Core/Clipboard/Profile/ImageProfile.cs b/src/SyncClipboard.Core/Clipboard/Profile/ImageProfile.cs index 75e243ed..33d912e9 100644 --- a/src/SyncClipboard.Core/Clipboard/Profile/ImageProfile.cs +++ b/src/SyncClipboard.Core/Clipboard/Profile/ImageProfile.cs @@ -23,8 +23,21 @@ public ImageProfile(ClipboardProfileDTO profileDTO) : base(profileDTO) public static async Task Create(IClipboardImage image, CancellationToken token) { - var fullPath = await Task.Run(() => SaveImageToFile(image)).WaitAsync(token); - return await Create(fullPath, token); + for (int i = 0; ; i++) + { + try + { + var fullPath = await Task.Run(() => SaveImageToFile(image)).WaitAsync(token); + return await Create(fullPath, token); + } + catch when (!token.IsCancellationRequested) + { + Logger.Write($"SaveImageToFile wrong time {i + 1}"); + if (i > 5) + throw; + } + await Task.Delay(100, token); + } } public static new async Task Create(string fullPath, CancellationToken token) diff --git a/src/SyncClipboard.Core/Models/ClipboardMetaInfomation.cs b/src/SyncClipboard.Core/Models/ClipboardMetaInfomation.cs index 9c4d50a1..be6361a7 100644 --- a/src/SyncClipboard.Core/Models/ClipboardMetaInfomation.cs +++ b/src/SyncClipboard.Core/Models/ClipboardMetaInfomation.cs @@ -10,7 +10,19 @@ public record class ClipboardMetaInfomation public string? Text; public string? Html; public IClipboardImage? Image; - public string[]? Files; + public string[]? _files; + public string[]? Files + { + get => _files; + set + { + _files = (string[]?)value?.Clone(); + if (_files != null) + { + Array.Sort(_files); + } + } + } public DragDropEffects? Effects; public string? OriginalType;