Commit f931d0f6 by Guba Sándor

storage: changed is_downloading and get_download_precentage

parent 1135d99d
......@@ -17,7 +17,8 @@ from acl.models import AclBase
from .tasks import local_tasks, remote_tasks
from celery.exceptions import TimeoutError
from manager.mancelery import celery
from common.models import ActivityModel, activitycontextimpl, WorkerNotFound
from common.models import (ActivityModel, activitycontextimpl,
WorkerNotFound, method_cache)
logger = logging.getLogger(__name__)
......@@ -111,6 +112,7 @@ class Disk(AclBase, TimeStampedModel):
return self.activity_log.filter(activity_code__endswith="deploy",
def path(self):
"""The path where the files are stored.
......@@ -153,15 +155,16 @@ class Disk(AclBase, TimeStampedModel):
def is_downloading(self):
da = DiskActivity.objects.filter(disk=self).latest("created")
return (da.activity_code == ""
and da.succeeded is None)
return self.activity_log.filter(
def get_download_percentage(self):
if not self.is_downloading():
return None
task = DiskActivity.objects.latest("created").task_uuid
task = self.activity_log.filter(
result = celery.AsyncResult(id=task)
......@@ -270,8 +273,7 @@ class Disk(AclBase, TimeStampedModel):
if self.ready:
return False
return True
with disk_activity(code_suffix='deploy', disk=self,
task_uuid=task_uuid, user=user) as act:
......@@ -289,9 +291,6 @@ class Disk(AclBase, TimeStampedModel):
self.ready = True
return True
def deploy_async(self, user=None):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment