From 49cb37eda2d756c284d8c250b3284c5243d06845 Mon Sep 17 00:00:00 2001 From: fram3d Date: Mon, 8 Apr 2024 00:53:34 +0200 Subject: [PATCH] add push and applyto functions --- lgit.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lgit.py b/lgit.py index 8dccfea..a4125ed 100755 --- a/lgit.py +++ b/lgit.py @@ -284,12 +284,25 @@ l dc values from base return appliedlogs + def applyto(self, destination)->int: + basecopy = destination.getbasecopy(self) + + appliedlogs = destination.applylogs(basecopy) + + return appliedlogs + def pullfrom(self, source)->int: self.fetchfrom(source) applied = self.applyfrom(source) return applied + def pushto(self, destination)->int: + destination.pullfrom(self) + pushed = destination.pullfrom(self) + + return pushed + def lastpwchangenow(self): ''' Return time of last password change for the user set to current time @@ -336,6 +349,15 @@ class lgit(): return appliedlogs + def applytoall(self, log_server: logserver)->int: + appliedlogs = 0 + + for destination in self.servers: + if destination != log_server: + appliedlogs += log_server.applyto(destination) + + return appliedlogs + def apply(self)->int: appliedlogs = 0 @@ -350,12 +372,24 @@ class lgit(): return pulled + def pushtoall(self, log_server: logserver)->int: + pushed = 0 + + for destination in self.servers: + if destination != log_server: + pushed += log_server.pushto(destination) + + return pushed + def pull(self)->int: self.fetch() pulled = self.apply() return pulled + def push(self)->int: + return self.pull() + def sync(self)->int: pulledlogs = self.pull()