diff --git a/zuul_registry/filesystem.py b/zuul_registry/filesystem.py index b68b9b2..e8157c6 100644 --- a/zuul_registry/filesystem.py +++ b/zuul_registry/filesystem.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this software. If not, see . +import logging import os import tempfile @@ -23,10 +24,13 @@ DISK_CHUNK_SIZE = 64 * 1024 class FilesystemDriver(storageutils.StorageDriver): + log = logging.getLogger('registry.filesystem') + def __init__(self, conf): self.root = conf['root'] def list_objects(self, path): + self.log.debug("List objects %s", path) path = os.path.join(self.root, path) if not os.path.isdir(path): return [] @@ -48,13 +52,18 @@ class FilesystemDriver(storageutils.StorageDriver): path = os.path.join(self.root, path) os.makedirs(os.path.dirname(path), exist_ok=True) with open(path, 'wb') as f: + size = 0 if isinstance(data, bytes): f.write(data) + size += len(data) else: for chunk in data: f.write(chunk) + size += len(chunk) f.flush() os.fsync(f.fileno()) + self.log.debug("[u: %s] Upload object %s size: %s", + uuid, path, size) def get_object(self, path): path = os.path.join(self.root, path) @@ -105,8 +114,12 @@ class FilesystemDriver(storageutils.StorageDriver): def move_object(self, src_path, dst_path, uuid=None): src_path = os.path.join(self.root, src_path) dst_path = os.path.join(self.root, dst_path) + self.log.debug("[u: %s] Move object %s %s", + uuid, src_path, dst_path) os.makedirs(os.path.dirname(dst_path), exist_ok=True) os.rename(src_path, dst_path) + self.log.debug("[u: %s] Moved object %s %s", + uuid, src_path, dst_path) def cat_objects(self, path, chunks, uuid=None): path = os.path.join(self.root, path)