From 7fff280c7945e979f860e9383b481d037e9fd754 Mon Sep 17 00:00:00 2001 From: meow Date: Sun, 5 Jan 2020 18:00:05 +0500 Subject: [PATCH] uncloud filescanner os.path.getsize expects str given Path instead --- uncloud/filescanner/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/uncloud/filescanner/main.py b/uncloud/filescanner/main.py index 89d32d4..19c43ef 100755 --- a/uncloud/filescanner/main.py +++ b/uncloud/filescanner/main.py @@ -43,7 +43,7 @@ def sha512sum(file: str): def track_file(file, base_dir): file_path = file.relative_to(base_dir) - + file_str = str(file) # Get Username try: owner = file_path.parts[0] @@ -51,18 +51,18 @@ def track_file(file, base_dir): pass else: file_path = file_path.relative_to(owner) - creation_date = time.ctime(os.stat(file).st_ctime) + creation_date = time.ctime(os.stat(file_str).st_ctime) entry_key = os.path.join(settings['etcd']['file_prefix'], str(uuid4())) entry_value = { 'filename': str(file_path), 'owner': owner, - 'sha512sum': sha512sum(str(file)), + 'sha512sum': sha512sum(file_str), 'creation_date': creation_date, - 'size': str(bitmath.Byte(os.path.getsize(str(file))).to_MB()), + 'size': str(bitmath.Byte(os.path.getsize(file_str)).to_MB()), } - logger.info('Tracking %s', file) + logger.info('Tracking %s', file_str) shared.etcd_client.put(entry_key, entry_value, value_in_json=True)