Fixed typo and changed OwnCloudExpiryTime to int

This commit is contained in:
Jonathan Donaldson 2018-09-10 22:14:32 +01:00
parent 334650d234
commit bfc9352300
3 changed files with 8 additions and 9 deletions

View file

@ -56,7 +56,7 @@ public override GenericUploader CreateUploader(UploadersConfig config, TaskRefer
DirectLink = config.OwnCloudDirectLink, DirectLink = config.OwnCloudDirectLink,
PreviewLink = config.OwnCloudUsePreviewLinks, PreviewLink = config.OwnCloudUsePreviewLinks,
IsCompatibility81 = config.OwnCloud81Compatibility, IsCompatibility81 = config.OwnCloud81Compatibility,
AutoEpxireTime = config.OwnCloudExpiryTime, AutoExpireTime = config.OwnCloudExpiryTime,
AutoExpire = config.OwnCloudAutoExpire AutoExpire = config.OwnCloudAutoExpire
}; };
} }
@ -70,7 +70,7 @@ public sealed class OwnCloud : FileUploader
public string Username { get; set; } public string Username { get; set; }
public string Password { get; set; } public string Password { get; set; }
public string Path { get; set; } public string Path { get; set; }
public string AutoEpxireTime { get; set; } public int AutoExpireTime { get; set; }
public bool CreateShare { get; set; } public bool CreateShare { get; set; }
public bool DirectLink { get; set; } public bool DirectLink { get; set; }
public bool PreviewLink { get; set; } public bool PreviewLink { get; set; }
@ -145,16 +145,15 @@ public string ShareFile(string path)
if (AutoExpire) if (AutoExpire)
{ {
if (string.IsNullOrEmpty(AutoEpxireTime)) if (AutoExpireTime == 0)
{ {
throw new Exception("ownCloud Auto Epxire Time is empty."); throw new Exception("ownCloud Auto Epxire Time is not valid.");
} }
else else
{ {
try try
{ {
int days = int.Parse(AutoEpxireTime); DateTime expireTime = DateTime.UtcNow.AddDays(AutoExpireTime);
DateTime expireTime = DateTime.UtcNow.AddDays(days);
args.Add("expireDate", $"{expireTime.Year}-{expireTime.Month}-{expireTime.Day}"); args.Add("expireDate", $"{expireTime.Year}-{expireTime.Month}-{expireTime.Day}");
} }
catch catch

View file

@ -589,7 +589,7 @@ public void LoadSettings()
txtOwnCloudUsername.Text = Config.OwnCloudUsername; txtOwnCloudUsername.Text = Config.OwnCloudUsername;
txtOwnCloudPassword.Text = Config.OwnCloudPassword; txtOwnCloudPassword.Text = Config.OwnCloudPassword;
txtOwnCloudPath.Text = Config.OwnCloudPath; txtOwnCloudPath.Text = Config.OwnCloudPath;
txtOwnCloudExpiryTime.Text = Config.OwnCloudExpiryTime; txtOwnCloudExpiryTime.Value = Config.OwnCloudExpiryTime;
cbOwnCloudCreateShare.Checked = Config.OwnCloudCreateShare; cbOwnCloudCreateShare.Checked = Config.OwnCloudCreateShare;
cbOwnCloudDirectLink.Checked = Config.OwnCloudDirectLink; cbOwnCloudDirectLink.Checked = Config.OwnCloudDirectLink;
cbOwnCloud81Compatibility.Checked = Config.OwnCloud81Compatibility; cbOwnCloud81Compatibility.Checked = Config.OwnCloud81Compatibility;
@ -2310,7 +2310,7 @@ private void txtOwnCloudPath_TextChanged(object sender, EventArgs e)
private void txtOwnExpiryTime_TextChanged(object sender, EventArgs e) private void txtOwnExpiryTime_TextChanged(object sender, EventArgs e)
{ {
Config.OwnCloudExpiryTime =txtOwnCloudExpiryTime.Value.ToString(); Config.OwnCloudExpiryTime = Convert.ToInt32(txtOwnCloudExpiryTime.Value);
} }
private void cbOwnCloudCreateShare_CheckedChanged(object sender, EventArgs e) private void cbOwnCloudCreateShare_CheckedChanged(object sender, EventArgs e)

View file

@ -293,7 +293,7 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
public string OwnCloudUsername = ""; public string OwnCloudUsername = "";
public string OwnCloudPassword = ""; public string OwnCloudPassword = "";
public string OwnCloudPath = "/"; public string OwnCloudPath = "/";
public string OwnCloudExpiryTime = "7"; public int OwnCloudExpiryTime = 7;
public bool OwnCloudCreateShare = true; public bool OwnCloudCreateShare = true;
public bool OwnCloudDirectLink = false; public bool OwnCloudDirectLink = false;
public bool OwnCloud81Compatibility = true; public bool OwnCloud81Compatibility = true;