changeset 1:27ccad26a830 default tip

Fixed resource expiration
author Ivo Smits <Ivo@UCIS.nl>
date Thu, 04 Dec 2014 21:45:51 +0100
parents 90ea68d4f92f
children
files ARClient/Form1.cs ARClient/MARC.cs
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ARClient/Form1.cs	Sat Nov 08 22:43:51 2014 +0100
+++ b/ARClient/Form1.cs	Thu Dec 04 21:45:51 2014 +0100
@@ -366,8 +366,7 @@
 						if (current.Serial >= resource.Serial) return false;
 						if (!current.CanUpdate(resource.Key)) return false;
 					} else {
-						if (!quick && resource.Value == null) return false;
-						if (!quick && resource.Expired) return false;
+						if (resource.CanDelete) return false;
 						current = null;
 					}
 					if (!quick && !resource.VerifySignature()) return false;
--- a/ARClient/MARC.cs	Sat Nov 08 22:43:51 2014 +0100
+++ b/ARClient/MARC.cs	Thu Dec 04 21:45:51 2014 +0100
@@ -140,7 +140,13 @@
 		public Boolean Expired {
 			get {
 				long currentTime = DateTimeToUnix(DateTime.UtcNow);
-				return (Serial + 365 * 24 * 60 * 60 < currentTime) || ((Expiration ?? UInt32.MaxValue) < currentTime);
+				return (Serial < currentTime - 365 * 24 * 60 * 60) || ((Expiration ?? long.MaxValue) < currentTime);
+			}
+		}
+		public Boolean CanDelete {
+			get {
+				long currentTime = DateTimeToUnix(DateTime.UtcNow);
+				return Serial < currentTime - 5 * 365 * 24 * 60 * 60;
 			}
 		}
 		public Boolean CanUpdate(MARCKey key) {