Skip to content

Commit

Permalink
git subrepo pull uno
Browse files Browse the repository at this point in the history
subrepo:
  subdir:   "uno"
  merged:   "c52477b"
upstream:
  origin:   "https://github.com/prrvchr/uno.git"
  branch:   "main"
  commit:   "c52477b"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"
  • Loading branch information
prrvchr committed Nov 4, 2024
1 parent f9102cb commit 5bf5d92
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 37 deletions.
4 changes: 2 additions & 2 deletions uno/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/prrvchr/uno.git
branch = main
commit = da72346ea80fb944699cce8d8bee8aa65ef46834
parent = ec24bf6dfdd5bfe2641ea42cc06812644189fc74
commit = c52477bd0abfa9de802a5c38224da5ffcce970cb
parent = f9102cba929d8567f622288115d2dfb98912c313
method = merge
cmdver = 0.4.3
15 changes: 8 additions & 7 deletions uno/lib/uno/ucb/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,14 @@ def getPushProperties(self, userid, itemid, start, end):
return properties

def updatePushItems(self, user, itemids):
call = self._getCall('updatePushItems')
call.setString(1, user.Id)
call.setArray(2, Array('VARCHAR', itemids))
call.execute()
timestamp = call.getObject(3, None)
call.close()
user.TimeStamp = timestamp
# XXX: We push items only if needed (ie: not empty)
if itemids:
call = self._getCall('updatePushItems')
call.setString(1, user.Id)
call.setArray(2, Array('VARCHAR', itemids))
call.execute()
user.TimeStamp = call.getObject(3, None)
call.close()

def getItemParentIds(self, itemid, metadata, start, end):
call = self._getCall('getItemParentIds')
Expand Down
63 changes: 39 additions & 24 deletions uno/lib/uno/ucb/replicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,26 @@ def run(self):

def _synchronize(self):
policy = self._getPolicy()
if policy == self._getSynchronizePolicy('NONE_IS_MASTER'):
return
self._logger.logprb(INFO, g_basename, '_synchronize()', 121)
if self._provider.isOffLine():
if policy == self._getSynchronizePolicy('NONE_IS_MASTER'):
self._logger.logprb(INFO, g_basename, '_synchronize()', 122)
elif policy == self._getSynchronizePolicy('SERVER_IS_MASTER'):
if not self._canceled:
self._pullUsers()
if not self._canceled:
self._pushUsers()
elif policy == self._getSynchronizePolicy('CLIENT_IS_MASTER'):
if not self._canceled:
self._pushUsers()
if not self._canceled:
self._pullUsers()
self._logger.logprb(INFO, g_basename, '_synchronize()', 123)

def _pullUsers(self):
elif self._provider.isOffLine():
self._logger.logprb(INFO, g_basename, '_synchronize()', 123)
else:
users = self._users.values()
if policy == self._getSynchronizePolicy('SERVER_IS_MASTER'):
users = self._pullUsers(users)
if users:
self._pushUsers(users)
elif policy == self._getSynchronizePolicy('CLIENT_IS_MASTER'):
users = self._pushUsers(users)
if users:
self._pullUsers(users)
self._logger.logprb(INFO, g_basename, '_synchronize()', 124)

def _pullUsers(self, users):
try:
for user in self._users.values():
for user in users:
if self._canceled:
break
self._logger.logprb(INFO, g_basename, '_pullUsers()', 201, user.Name)
Expand All @@ -141,6 +141,9 @@ def _pullUsers(self):
else:
self._pullUser(user)
self._logger.logprb(INFO, g_basename, '_pullUsers()', 202, user.Name)
else:
return users
return None
except Exception as e:
self._logger.logprb(SEVERE, g_basename, '_pullUsers()', 203, e, traceback.format_exc())

Expand Down Expand Up @@ -180,30 +183,42 @@ def _pullUser(self, user):
user.setToken(token)
self._logger.logprb(INFO, g_basename, '_pullUser()', 231, user.Name, count, pages, token)

def _pushUsers(self):
def _pushUsers(self, users):
# This procedure is launched each time the synchronization is started
# This procedure corresponds to the push of changes for the entire database
# for all users, in chronological order, from 'start' to 'end'...
try:
pusers = []
end = currentDateTimeInTZ()
for user in self._users.values():
for user in users:
if self._canceled:
break
self._logger.logprb(INFO, g_basename, '_pushUsers()', 301, user.Name)
if self._isNewUser(user):
self._initUser(user)
item = None
items = []
start = user.TimeStamp
for item in self.DataBase.getPushItems(user.Id, start, end):
if self._canceled:
break
metadata = self.DataBase.getMetaData(user, item)
newid = self._pushItem(user, item, metadata, start, end)
if newid is not None:
items.append(newid)
else:
if newid is None:
modified = getDateTimeToString(metadata.get('DateModified'))
self._logger.logprb(SEVERE, g_basename, '_pushUsers()', 302, metadata.get('Title'), modified, metadata.get('Id'))
break
if items:
else:
items.append(newid)
else:
# XXX: User was pushed, we update user timestamp if needed
self.DataBase.updatePushItems(user, items)
self._logger.logprb(INFO, g_basename, '_pushUsers()', 303, user.Name)
self._logger.logprb(INFO, g_basename, '_pushUsers()', 303, user.Name)
continue
break
else:
return users
return None
except Exception as e:
self._logger.logprb(SEVERE, g_basename, '_pushUsers()', 304, e, traceback.format_exc())

Expand Down
5 changes: 3 additions & 2 deletions uno/resource/ucb/Replicator_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

120=Replicator._synchronize()
121=Starting data synchronization.
122=Synchronization is not possible network is offline!!!
123=End of data synchronization.
122=Synchronization has been disabled!!!
123=Synchronization is not possible network is offline!!!
124=End of data synchronization.

200=Replicator._pullUsers()
201=Starting data download for user: {}.
Expand Down
5 changes: 3 additions & 2 deletions uno/resource/ucb/Replicator_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
120=Replicator._synchronize()
121=D\u00e9marrage de la synchronisation des donn\u00e9es.
122=La synchronisation n'est pas possible le r\u00e9seau est hors ligne!!!
123=Fin de la synchronisation des donn\u00e9es.
122=La synchronisation a été désactivée!!!
123=La synchronisation n'est pas possible le r\u00e9seau est hors ligne!!!
124=Fin de la synchronisation des donn\u00e9es.

200=Replicator._pullUsers()
201=D\u00e9marrage du t\u00e9l\u00e9chargement des donn\u00e9es pour l'utilisateur: {}.
Expand Down

0 comments on commit 5bf5d92

Please sign in to comment.