Skip to content

Commit

Permalink
Use quota manager to calculate "active project storage used".
Browse files Browse the repository at this point in the history
The 'active_project_storage_used' method is used to report "how much
of the storage allowance for the given project submission has been
used."

(The name suggests that this is somehow similar to
'published_project_storage_used', but this is not the case: *that*
method is used to inform visitors "how large will the project files be
if I download all of them", which is only tangentially related to the
resource usage that a particular submission is responsible for.)

Reporting (as well as limiting) resource usage is the task of the
QuotaManager.  Use the QuotaManager API and remove the redundant
ProjectFiles API.
  • Loading branch information
Benjamin Moody committed Sep 22, 2023
1 parent 89755b1 commit 4152ef0
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 12 deletions.
2 changes: 1 addition & 1 deletion physionet-django/project/modelcomponents/activeproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def storage_used(self):
versions of this CoreProject. (The QuotaManager should ensure
that the same file is not counted twice in this total.)
"""
current = self.files.active_project_storage_used(self)
current = self.quota_manager().bytes_used
published = self.core_project.total_published_size

return current + published
Expand Down
5 changes: 0 additions & 5 deletions physionet-django/project/projectfiles/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ def project_quota_manager(self, project):
"""Create a quota manager for a project."""
raise NotImplementedError

@abc.abstractmethod
def active_project_storage_used(self, project):
"""Total storage used in bytes - active project."""
raise NotImplementedError

@abc.abstractmethod
def published_project_storage_used(self, project):
"""Total storage used in bytes - published project."""
Expand Down
3 changes: 0 additions & 3 deletions physionet-django/project/projectfiles/gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ def project_quota_manager(self, project):
quota_manager.set_limits(bytes_hard=limit, bytes_soft=limit)
return quota_manager

def active_project_storage_used(self, project):
return self._storage_used(project)

def published_project_storage_used(self, project):
return self._storage_used(project)

Expand Down
3 changes: 0 additions & 3 deletions physionet-django/project/projectfiles/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ def project_quota_manager(self, project):
quota_manager.set_limits(bytes_hard=limit, bytes_soft=limit)
return quota_manager

def active_project_storage_used(self, project):
return project.quota_manager().bytes_used

def published_project_storage_used(self, project):
return get_tree_size(project.file_root())

Expand Down

0 comments on commit 4152ef0

Please sign in to comment.