2a105fa8046ddad8a10d7c71bcde1c86c4244dd0 — Julien Floret 3 months ago 171c374
fs: fix duplicated user repository objects

Because UserRepository objects contain stateful data (eg disk_usage),
the instances must be created and accessed via the
ArtifactRepository.get_user_repo() method, which handles a persistent
UserRepository dict.

Before this patch however, the UserRepository.all() class method used
to create loose UserRepository objects on demand.

As a consequence, the disk_usage_refresh() method (called by the
periodic fs cleanup) was working on a temporary object, thus the
disk_usage parameter was not properly reset in the "real"
UserRepository object, creating inconsistencies between the content of
".disk_usage" and the value displayed on the web UI.

Fix UserRepository.all() to access the right instances.

Fixes: bd1c23893882 ("server: add filesystem api")
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Thomas Faivre <thomas.faivre@6wind.com>
1 files changed, 1 insertions(+), 1 deletions(-)

M dlrepo/fs/__init__.py
M dlrepo/fs/__init__.py => dlrepo/fs/__init__.py +1 -1
@@ 295,7 295,7 @@ class UserRepository(AbstractRepository):
        for d in path.iterdir():
            if not d.is_dir():
            yield cls(base, d.name)
            yield base.get_user_repo(d.name)

    def _parse_disk_usage_file(self) -> int:
        du_path = self.path() / ".disk_usage"