[chronojump] Fixed potentially bugs on utilDate and jumps
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixed potentially bugs on utilDate and jumps
- Date: Sat, 18 Jul 2020 22:06:49 +0000 (UTC)
commit 0855b07f75b7ddc3fbec17ced7d8fd86ffeb1f07
Author: Xavier de Blas <xaviblas gmail com>
Date: Sun Jul 19 00:06:25 2020 +0200
Fixed potentially bugs on utilDate and jumps
src/sqlite/jump.cs | 14 ++++++++++++++
src/utilDate.cs | 9 ++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/src/sqlite/jump.cs b/src/sqlite/jump.cs
index 96e650a5..7baba9ae 100644
--- a/src/sqlite/jump.cs
+++ b/src/sqlite/jump.cs
@@ -418,9 +418,23 @@ class SqliteJump : Sqlite
//jumps previous to DB 1.82 have no datetime on jump
//find session datetime for that jumps
if(jmp.Datetime == "")
+ {
+ bool found = false;
foreach(Session session in session_l)
+ {
if(session.UniqueID == jmp.SessionID)
+ {
jmp.Datetime = UtilDate.ToFile(session.Date);
+ found = true;
+ break;
+ }
+
+ }
+ //on really old versions of Chronojump, deleting a session maybe does not delete
the jumps
+ //so could be to found a jump without a session, so assign here the MinValue
possible of DateTime
+ if(! found)
+ jmp.Datetime = UtilDate.ToFile(DateTime.MinValue);
+ }
if(personNameInComment)
foreach(Person person in person_l)
diff --git a/src/utilDate.cs b/src/utilDate.cs
index 2285b9bd..8ea1f2dc 100644
--- a/src/utilDate.cs
+++ b/src/utilDate.cs
@@ -56,10 +56,17 @@ public class UtilDate
//used also on SQL when time wants to be stored also
public static DateTime FromFile (string s)
{
- //TODO: check possible errors
string [] allFull = s.Split(new char[] {'_'});
+
+ if(allFull.Length != 2)
+ return DateTime.MinValue;
+
string [] dateFull = allFull[0].Split(new char[] {'-'});
string [] timeFull = allFull[1].Split(new char[] {'-'});
+
+ if(dateFull.Length != 3 || timeFull.Length != 3)
+ return DateTime.MinValue;
+
return new DateTime(
Convert.ToInt32(dateFull[0]),
Convert.ToInt32(dateFull[1]),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]