[gnote] Switch filesystemsyncserver from sharp::DateTime to Glib::DateTime



commit fa8539458132e2c28e56c01e6be29538881f42b1
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Jan 25 15:04:10 2020 +0200

    Switch filesystemsyncserver from sharp::DateTime to Glib::DateTime

 src/synchronization/filesystemsyncserver.cpp | 10 +++++-----
 src/synchronization/filesystemsyncserver.hpp |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/src/synchronization/filesystemsyncserver.cpp b/src/synchronization/filesystemsyncserver.cpp
index 7f171576..bfe75e56 100644
--- a/src/synchronization/filesystemsyncserver.cpp
+++ b/src/synchronization/filesystemsyncserver.cpp
@@ -194,18 +194,18 @@ bool FileSystemSyncServer::begin_sync_transaction()
   // client should record the time elapsed
   if(m_lock_path->query_exists()) {
     SyncLockInfo currentSyncLock = current_sync_lock();
-    if(m_initial_sync_attempt == sharp::DateTime()) {
+    if(!m_initial_sync_attempt) {
       DBG_OUT("Sync: Discovered a sync lock file, wait at least %s before trying again.", 
sharp::time_span_string(currentSyncLock.duration).c_str());
       // This is our initial attempt to sync and we've detected
       // a sync file, so we're gonna have to wait.
-      m_initial_sync_attempt = sharp::DateTime::now();
+      m_initial_sync_attempt = Glib::DateTime::create_now_local();
       m_last_sync_lock_hash = currentSyncLock.hash_string();
       return false;
     }
     else if(m_last_sync_lock_hash != currentSyncLock.hash_string()) {
       DBG_OUT("Sync: Updated sync lock file discovered, wait at least %s before trying again.", 
sharp::time_span_string(currentSyncLock.duration).c_str());
       // The sync lock has been updated and is still a valid lock
-      m_initial_sync_attempt = sharp::DateTime::now();
+      m_initial_sync_attempt = Glib::DateTime::create_now_local();
       m_last_sync_lock_hash = currentSyncLock.hash_string();
       return false;
     }
@@ -214,7 +214,7 @@ bool FileSystemSyncServer::begin_sync_transaction()
         // The sync lock has is the same so check to see if the
         // duration of the lock has expired.  If it hasn't, wait
         // even longer.
-        if(sharp::DateTime::now() - currentSyncLock.duration < m_initial_sync_attempt) {
+        if(Glib::DateTime::create_now_local().add(-currentSyncLock.duration) < m_initial_sync_attempt) {
           DBG_OUT("Sync: You haven't waited long enough for the sync file to expire.");
           return false;
         }
@@ -226,7 +226,7 @@ bool FileSystemSyncServer::begin_sync_transaction()
   }
 
   // Reset the initialSyncAttempt
-  m_initial_sync_attempt = sharp::DateTime();
+  m_initial_sync_attempt = Glib::DateTime();
   m_last_sync_lock_hash = "";
 
   // Create a new lock file so other clients know another client is
diff --git a/src/synchronization/filesystemsyncserver.hpp b/src/synchronization/filesystemsyncserver.hpp
index ca33b6fa..d5b32b7a 100644
--- a/src/synchronization/filesystemsyncserver.hpp
+++ b/src/synchronization/filesystemsyncserver.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2012-2013,2017-2019 Aurimas Cernius
+ * Copyright (C) 2012-2013,2017-2020 Aurimas Cernius
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -69,7 +69,7 @@ private:
   int m_new_revision;
   Glib::RefPtr<Gio::File> m_new_revision_path;
 
-  sharp::DateTime m_initial_sync_attempt;
+  Glib::DateTime m_initial_sync_attempt;
   Glib::ustring m_last_sync_lock_hash;
   utils::InterruptableTimeout m_lock_timeout;
   SyncLockInfo m_sync_lock;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]