From da7feed2ef8b327d567c5218eaabc229909c4b2e Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 29 Oct 2019 04:57:27 -0400 Subject: [PATCH] Return st_nlink of 1 for mirrored index files GitLab issue #676. Thanks to Ezio Vernacotola (@eziove) for the report and solution. Signed-off-by: Roberto Rosario --- HISTORY.rst | 2 ++ docs/releases/3.2.9.rst | 1 + mayan/apps/mirroring/filesystems.py | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index bb405e26e7..2186ded3d8 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -23,6 +23,8 @@ - Move Celery and Django Celery dependencies to the task manager app. - Improve dependecies app tests. +- Return st_nlink of 1 files in mirrored indexes. GitLab issue #676. + Thanks to Ezio Vernacotola (@eziove) for the report and solution. 3.2.8 (2019-10-01) ================== diff --git a/docs/releases/3.2.9.rst b/docs/releases/3.2.9.rst index 932544a3a8..56b18f5e0d 100644 --- a/docs/releases/3.2.9.rst +++ b/docs/releases/3.2.9.rst @@ -99,6 +99,7 @@ Backward incompatible changes Bugs fixed or issues closed --------------------------- +- :gitlab-issue:`676` Access fuse mounted index via samba - :gitlab-issue:`677` Django start before PostgreSQL is up. - :forum-topic:`1347` Workflow state action: perform a POST request diff --git a/mayan/apps/mirroring/filesystems.py b/mayan/apps/mirroring/filesystems.py index d4c600267e..76e2808a4f 100644 --- a/mayan/apps/mirroring/filesystems.py +++ b/mayan/apps/mirroring/filesystems.py @@ -146,6 +146,9 @@ class IndexFilesystem(Operations): if not result: raise FuseOSError(ENOENT) + # st_nlink tracks the number of hard links to a file. + # Must be 2 for directories and at least 1 for files + # https://www.gnu.org/software/libc/manual/html_node/Attribute-Meanings.html if isinstance(result, IndexInstanceNode): return { 'st_mode': (S_IFDIR | DIRECTORY_MODE), 'st_ctime': now, @@ -161,7 +164,8 @@ class IndexFilesystem(Operations): result.latest_version.timestamp.replace(tzinfo=None) - result.latest_version.timestamp.utcoffset() - datetime.datetime(1970, 1, 1) ).total_seconds(), 'st_atime': now, - 'st_size': result.size + 'st_size': result.size, + 'st_nlink': 1 } def open(self, path, flags):