fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
changes from server
[wolnelektury.git]
/
apps
/
waiter
/
models.py
diff --git
a/apps/waiter/models.py
b/apps/waiter/models.py
index
10f9289
..
bffaf7f
100644
(file)
--- a/
apps/waiter/models.py
+++ b/
apps/waiter/models.py
@@
-1,3
+1,7
@@
+# -*- coding: utf-8 -*-
+# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
from os.path import join, isfile
from django.core.urlresolvers import reverse
from django.db import models
from os.path import join, isfile
from django.core.urlresolvers import reverse
from django.db import models
@@
-15,7
+19,7
@@
class WaitedFile(models.Model):
@classmethod
def exists(cls, path):
"""Returns opened file or None.
@classmethod
def exists(cls, path):
"""Returns opened file or None.
-
+
`path` is relative to WAITER_ROOT.
Won't open a path leading outside of WAITER_ROOT.
"""
`path` is relative to WAITER_ROOT.
Won't open a path leading outside of WAITER_ROOT.
"""
@@
-35,14
+39,6
@@
class WaitedFile(models.Model):
cls.objects.count() < WAITER_MAX_QUEUE
)
cls.objects.count() < WAITER_MAX_QUEUE
)
- def is_stale(self):
- if self.task is None:
- # Race; just let the other task roll.
- return False
- if self.task.status not in (u'PENDING', u'STARTED', u'SUCCESS', u'RETRY'):
- return True
- return False
-
@classmethod
def order(cls, path, task_creator, description=None):
"""
@classmethod
def order(cls, path, task_creator, description=None):
"""
@@
-57,7
+53,7
@@
class WaitedFile(models.Model):
if not already:
waited, created = cls.objects.get_or_create(path=path)
if created or waited.is_stale():
if not already:
waited, created = cls.objects.get_or_create(path=path)
if created or waited.is_stale():
- waited.task = task_creator(check_abspath(path))
+ waited.task = task_creator(check_abspath(path)
, waited.pk
)
waited.task_id = waited.task.task_id
waited.description = description
waited.save()
waited.task_id = waited.task.task_id
waited.description = description
waited.save()