Skip to content

Commit

Permalink
功能:可以设置重试次数,失败超过重试次数下载/上传会暂停
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeric-X committed Jul 21, 2024
1 parent fc1529e commit 4f7f562
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 12 deletions.
4 changes: 4 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v2.8.3.1
- 功能:可以设置重试次数,失败超过重试次数下载/上传会暂停(#100)
- 功能:可以设置剪切文件时不上传(#107)

v2.8.3
- 修复:不设置hash上传图片/文件到服务器后,桌面客户端会无限重复设置剪贴板
- 修复:远程文件不存在时,只报错一次,不再无限弹窗、图标错乱(#87)
Expand Down
4 changes: 2 additions & 2 deletions build/macos/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<key>NSHighResolutionCapable</key>
<true/>
<key>CFBundleVersion</key>
<string>0.7.4</string>
<string>0.7.4.1</string>
<key>CFBundleShortVersionString</key>
<string>0.7.4</string>
<string>0.7.4.1</string>
</dict>
</plist>
9 changes: 9 additions & 0 deletions src/SyncClipboard.Core/I18n/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/SyncClipboard.Core/I18n/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -522,4 +522,7 @@
<data name="DoNotUploadWhenCut" xml:space="preserve">
<value>Don't Upload When Cutting Files</value>
</data>
<data name="RetryTimes" xml:space="preserve">
<value>Retry Times</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/SyncClipboard.Core/I18n/Strings.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -522,4 +522,7 @@
<data name="DoNotUploadWhenCut" xml:space="preserve">
<value>剪切文件时不上传</value>
</data>
<data name="RetryTimes" xml:space="preserve">
<value>重试次数</value>
</data>
</root>
2 changes: 1 addition & 1 deletion src/SyncClipboard.Core/Models/UserConfigs/SyncConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public record class SyncConfig
public bool TrustInsecureCertificate { get; set; } = false;
public uint MaxFileByte { get; set; } = 1024 * 1024 * 20; // 20MB
public uint IntervalTime { get; set; } = 3;
public int RetryTimes { get; set; } = 3;
public uint RetryTimes { get; set; } = 3;
public uint TimeOut { get; set; } = 100;
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ private async void StartPullLoop()
_toastReporter = null;
_logger.Write(LOG_TAG, "Canceled");
}
catch (Exception ex)
{
_logger.Write(LOG_TAG, ex.Message);
}
}

private void StopPullLoop()
Expand Down Expand Up @@ -272,18 +276,15 @@ public void PushStoppedHandler()
private void SetStatusOnError(ref int errorTimes, Exception ex)
{
errorTimes++;
if (errorTimes == 2)
{
_trayIcon.SetStatusString(SERVICE_NAME, $"Error. Failed times: {errorTimes}.\n{ex.Message}", true);
}
_trayIcon.SetStatusString(SERVICE_NAME, $"Error. Failed times: {errorTimes}.\n{ex.Message}", true);

_logger.Write(ex.ToString());
if (errorTimes == _syncConfig.RetryTimes)
if (errorTimes > _syncConfig.RetryTimes)
{
_notificationManager.SendText(I18n.Strings.FailedToDownloadClipboard, ex.Message);
throw new Exception("Download retry times reach limit");
}
}

private async Task PullLoop(CancellationToken cancelToken)
{
int errorTimes = 0;
Expand All @@ -304,9 +305,9 @@ private async Task PullLoop(CancellationToken cancelToken)
ex = new Exception("Request timeout");
}

SetStatusOnError(ref errorTimes, ex);
_toastReporter?.Cancel();
_toastReporter = null;
SetStatusOnError(ref errorTimes, ex);
}
finally
{
Expand Down
6 changes: 6 additions & 0 deletions src/SyncClipboard.Core/ViewModels/SyncSettingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ partial void OnServerConfigChanged(ServerConfig value)
private uint intervalTime;
partial void OnIntervalTimeChanged(uint value) => ClientConfig = ClientConfig with { IntervalTime = value };

[ObservableProperty]
private uint retryTimes;
partial void OnRetryTimesChanged(uint value) => ClientConfig = ClientConfig with { RetryTimes = value };

[ObservableProperty]
private uint timeOut;
partial void OnTimeOutChanged(uint value) => ClientConfig = ClientConfig with { TimeOut = value };
Expand Down Expand Up @@ -78,6 +82,7 @@ partial void OnServerConfigChanged(ServerConfig value)
partial void OnClientConfigChanged(SyncConfig value)
{
IntervalTime = value.IntervalTime;
RetryTimes = value.RetryTimes;
SyncEnable = value.SyncSwitchOn;
UseLocalServer = value.UseLocalServer;
TimeOut = value.TimeOut;
Expand Down Expand Up @@ -144,6 +149,7 @@ public SyncSettingViewModel(ConfigManager configManager, MainViewModel mainViewM
_configManager.ListenConfig<SyncConfig>(config => ClientConfig = config);
clientConfig = _configManager.GetConfig<SyncConfig>();
intervalTime = clientConfig.IntervalTime;
retryTimes = clientConfig.RetryTimes;
syncEnable = clientConfig.SyncSwitchOn;
useLocalServer = clientConfig.UseLocalServer;
timeOut = clientConfig.TimeOut;
Expand Down
2 changes: 1 addition & 1 deletion src/SyncClipboard.Desktop/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal class AppConfig : IAppConfig
{
public string AppId => Env.AppId;
public string AppStringId => "SyncClipboard.Desktop";
public string AppVersion => "0.7.4";
public string AppVersion => "0.7.4.1";
public string UpdateApiUrl => "https://api.github.com/repos/Jeric-X/SyncClipboard.Desktop/releases";
public string UpdateUrl => "https://github.com/Jeric-X/SyncClipboard.Desktop/releases/latest";
}
4 changes: 4 additions & 0 deletions src/SyncClipboard.Desktop/Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.7.4.1
- 功能:可以设置重试次数,失败超过重试次数下载/上传会暂停(https://github.com/Jeric-X/SyncClipboard/issues/100)
- 功能:可以设置剪切文件时不上传(https://github.com/Jeric-X/SyncClipboard/issues/107)

0.7.4
- 修复:不设置hash上传图片/文件到服务器后,桌面客户端会无限重复设置剪贴板
- 修复:在一些场景复制图片时,无法触发上传(https://github.com/Jeric-X/SyncClipboard/issues/88)
Expand Down
5 changes: 5 additions & 0 deletions src/SyncClipboard.Desktop/Views/SyncSettingPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@
<ui:NumberBox Minimum="0" Maximum="100000" Value="{Binding IntervalTime, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.RetryTimes}">
<ui:SettingsExpanderItem.Footer>
<ui:NumberBox Minimum="0" Maximum="100000" Value="{Binding RetryTimes, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.TimeoutPeriod}">
<ui:SettingsExpanderItem.Footer>
<ui:NumberBox Minimum="0" Maximum="100000" Value="{Binding TimeOut, Mode=TwoWay}" />
Expand Down
2 changes: 1 addition & 1 deletion src/SyncClipboard.WinUI3/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal class AppConfig : IAppConfig
{
public string AppId => Env.AppId;
public string AppStringId => "SyncClipboard.WinUI";
public string AppVersion => "2.8.3";
public string AppVersion => "2.8.3.1";
public string UpdateApiUrl => "https://api.github.com/repos/Jeric-X/SyncClipboard/releases";
public string UpdateUrl => "https://github.com/Jeric-X/SyncClipboard/releases/latest";
}
3 changes: 3 additions & 0 deletions src/SyncClipboard.WinUI3/Views/SyncSettingPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
<ui:SettingsCard Header="{x:Bind i18n:Strings.QueryInterval}">
<NumberBox Minimum="0" Maximum="100000" Value="{x:Bind _viewModel.IntervalTime, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.RetryTimes}">
<NumberBox Minimum="0" Maximum="100000" Value="{x:Bind _viewModel.RetryTimes, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.TimeoutPeriod}">
<NumberBox Minimum="0" Maximum="100000" Value="{x:Bind _viewModel.TimeOut, Mode=TwoWay}" />
</ui:SettingsCard>
Expand Down

0 comments on commit 4f7f562

Please sign in to comment.