]> git.ipfire.org Git - pbs.git/commitdiff
sync: Write timestamp so that we can track when mirrors were synced last
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 1 Sep 2023 16:16:33 +0000 (16:16 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 1 Sep 2023 16:16:33 +0000 (16:16 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/__init__.py

index 2141a6e4bf990592a291515b2bf8f0203c892ec2..aae8535204a5ffb6845455288b58e59fa96db38b 100644 (file)
@@ -3,6 +3,7 @@
 import aiofiles
 import asyncio
 import configparser
+import datetime
 import inspect
 import logging
 import os
@@ -537,11 +538,14 @@ class Backend(object):
                        log.warning("No sync target configured")
                        return 0
 
+               # Update the timestamp
+               await self._update_timestamp()
+
                commandline = [
                        "rsync",
 
                        # Show what is being transferred
-                       #"--verbose",
+                       "--verbose",
 
                        # Compress any transferred data
                        "--compress",
@@ -567,6 +571,9 @@ class Backend(object):
                        # Add source & target
                        "%s/" % self.basepath,
                        target,
+
+                       # Sync the .timestamp
+                       "--include=.timestamp",
                ]
 
                # Add all mirrored repositories
@@ -581,6 +588,19 @@ class Backend(object):
                # Run command
                await self.command(*commandline, krb5_auth=True)
 
+       async def _update_timestamp(self):
+               """
+                       Updates the .timestamp file in the root of the exported files
+               """
+               # Make filename
+               path = os.path.join(self.basepath, ".timestamp")
+
+               t = datetime.datetime.utcnow()
+
+               # Write the current time as seconds since epoch
+               async with aiofiles.open(path, mode="w") as f:
+                       await f.write(t.strftime("%s"))
+
 
 def setup_logging():
        """