mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Fix "log list" : use root_dir for iglob / make sure we use absolute paths (#1913)
* use root_dir for iglob, fix parent_symlink path and check if it exists * fix log path * do not try to read a yaml of a symlink to /dev/null * use hidden files, needs python 3.11 (bookworm) * don't worry, I'm an expert! * Update log.py: log_file -> log_md_fullpath (otherwise it feel like log_file refers to the .log) * Update log.py: remove debug statement * Update log.py: revert unecessary if change --------- Co-authored-by: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com>
This commit is contained in:
parent
f11f11973b
commit
ebcf3c79ff
1 changed files with 4 additions and 4 deletions
|
@ -87,9 +87,10 @@ def _update_log_parent_symlinks():
|
||||||
|
|
||||||
one_year_ago = time.time() - 365 * 24 * 3600
|
one_year_ago = time.time() - 365 * 24 * 3600
|
||||||
|
|
||||||
logs = glob.iglob(OPERATIONS_PATH + "*" + METADATA_FILE_EXT)
|
logs = glob.iglob("*" + METADATA_FILE_EXT, root_dir=OPERATIONS_PATH)
|
||||||
for log_md in logs:
|
for log_md in logs:
|
||||||
if os.path.getctime(log_md) < one_year_ago:
|
log_md_fullpath = os.path.join(OPERATIONS_PATH, log_md)
|
||||||
|
if os.path.getctime(log_md_fullpath) < one_year_ago:
|
||||||
# Let's ignore files older than one year because hmpf reading a shitload of yml is not free
|
# Let's ignore files older than one year because hmpf reading a shitload of yml is not free
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -100,7 +101,7 @@ def _update_log_parent_symlinks():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
metadata = (
|
metadata = (
|
||||||
read_yaml(log_md) or {}
|
read_yaml(log_md_fullpath) or {}
|
||||||
) # Making sure this is a dict and not None..?
|
) # Making sure this is a dict and not None..?
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# If we can't read the yaml for some reason, report an error and ignore this entry...
|
# If we can't read the yaml for some reason, report an error and ignore this entry...
|
||||||
|
@ -110,7 +111,6 @@ def _update_log_parent_symlinks():
|
||||||
parent = metadata.get("parent")
|
parent = metadata.get("parent")
|
||||||
parent = parent + METADATA_FILE_EXT if parent else "/dev/null"
|
parent = parent + METADATA_FILE_EXT if parent else "/dev/null"
|
||||||
try:
|
try:
|
||||||
print(parent, parent_symlink)
|
|
||||||
os.symlink(parent, parent_symlink)
|
os.symlink(parent, parent_symlink)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to create symlink {parent_symlink} ? {e}")
|
logger.warning(f"Failed to create symlink {parent_symlink} ? {e}")
|
||||||
|
|
Loading…
Add table
Reference in a new issue