Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
79d910dc
authored
Mar 21, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-storage-trash'
Fine-tune and test storage garbage collector
parents
8d004e78
6edddd59
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
circle/storage/models.py
+3
-5
circle/storage/tests/test_models.py
+5
-1
No files found.
circle/storage/models.py
View file @
79d910dc
...
...
@@ -12,7 +12,6 @@ from django.utils import timezone
from
django.utils.translation
import
ugettext_lazy
as
_
from
model_utils.models
import
TimeStampedModel
from
sizefield.models
import
FileSizeField
from
datetime
import
timedelta
from
acl.models
import
AclBase
from
.tasks
import
local_tasks
,
remote_tasks
...
...
@@ -203,9 +202,7 @@ class Disk(AclBase, TimeStampedModel):
"""True if the associated file can be deleted.
"""
# Check if all children and the disk itself is destroyed.
yesterday
=
timezone
.
now
()
-
timedelta
(
days
=
1
)
return
(
self
.
destroyed
is
not
None
and
self
.
destroyed
<
yesterday
)
and
self
.
children_deletable
return
(
self
.
destroyed
is
not
None
)
and
self
.
children_deletable
@property
def
children_deletable
(
self
):
...
...
@@ -345,7 +342,8 @@ class Disk(AclBase, TimeStampedModel):
"""Create disk with activity.
"""
datastore
=
params
.
pop
(
'datastore'
,
DataStore
.
objects
.
get
())
disk
=
cls
(
filename
=
str
(
uuid
.
uuid4
()),
datastore
=
datastore
,
**
params
)
filename
=
params
.
pop
(
'filename'
,
str
(
uuid
.
uuid4
()))
disk
=
cls
(
filename
=
filename
,
datastore
=
datastore
,
**
params
)
disk
.
clean
()
disk
.
save
()
logger
.
debug
(
"Disk created:
%
s"
,
params
)
...
...
circle/storage/tests/test_models.py
View file @
79d910dc
...
...
@@ -31,7 +31,7 @@ class DiskTestCase(TestCase):
def
test_deletable_newly_destroyed
(
self
):
d
=
self
.
_disk
(
destroyed
=
new
)
assert
not
d
.
is_deletable
assert
d
.
is_deletable
def
test_deletable_no_child
(
self
):
d
=
self
.
_disk
(
destroyed
=
old
)
...
...
@@ -86,3 +86,7 @@ class DiskTestCase(TestCase):
d
=
MagicMock
(
spec
=
Disk
)
d
.
is_downloading
=
Mock
(
return_value
=
False
)
assert
Disk
.
get_download_percentage
(
d
)
is
None
def
test_undeployed_disk_ready
(
self
):
d
=
self
.
_disk
()
assert
not
d
.
ready
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment