From 1a47a24e007bc22d215c16e93a8cb2248c451e7a Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 1 Sep 2023 16:16:33 +0000 Subject: [PATCH] sync: Write timestamp so that we can track when mirrors were synced last Signed-off-by: Michael Tremer --- src/buildservice/__init__.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/buildservice/__init__.py b/src/buildservice/__init__.py index 2141a6e..aae8535 100644 --- a/src/buildservice/__init__.py +++ b/src/buildservice/__init__.py @@ -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(): """ -- 2.39.2