Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ee6fcceb
authored
Feb 21, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: first version of gathering incosistent images
parent
36e51381
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
circle/storage/tasks/periodic_tasks.py
+43
-0
No files found.
circle/storage/tasks/periodic_tasks.py
0 → 100644
View file @
ee6fcceb
from
storage.models
import
DataStore
import
os
from
django.utils
import
timezone
from
datetime
import
timedelta
from
manager.mancelery
import
celery
import
logging
logger
=
logging
.
getLogger
(
__name__
)
@celery.task
def
garbage_collector
():
logging
.
warning
(
"Deletable disks:"
)
for
ds
in
DataStore
.
objects
.
all
():
one_week_before
=
timezone
.
now
()
-
timedelta
(
days
=
7
)
file_list
=
os
.
listdir
(
ds
.
path
)
disk_list
=
[
disk
.
filename
for
disk
in
ds
.
disk_set
.
filter
(
destroyed__lt
=
one_week_before
)]
for
i
in
set
(
file_list
)
.
intersection
(
disk_list
):
abs_path
=
ds
.
path
+
"/"
+
i
logging
.
warning
(
i
+
" - "
+
str
(
os
.
path
.
getsize
(
abs_path
)
/
1024
/
1024
))
#os.unlink(abs_path)
logging
.
warning
(
"Orphan disks:"
)
for
ds
in
DataStore
.
objects
.
all
():
one_week_before
=
timezone
.
now
()
-
timedelta
(
days
=
7
)
file_list
=
os
.
listdir
(
ds
.
path
)
disk_list
=
[
disk
.
filename
for
disk
in
ds
.
disk_set
.
all
()]
for
i
in
set
(
file_list
)
.
difference
(
disk_list
):
if
"dump"
not
in
i
:
abs_path
=
ds
.
path
+
"/"
+
i
logging
.
warning
(
i
+
" - "
+
str
(
os
.
path
.
getsize
(
abs_path
)
/
1024
/
1024
))
logging
.
warning
(
"Missing disks:"
)
for
ds
in
DataStore
.
objects
.
all
():
one_week_before
=
timezone
.
now
()
-
timedelta
(
days
=
7
)
file_list
=
os
.
listdir
(
ds
.
path
)
disk_list
=
[
disk
.
filename
for
disk
in
ds
.
disk_set
.
filter
(
destroyed__isnull
=
False
)]
for
i
in
set
(
disk_list
)
.
difference
(
file_list
):
logging
.
warning
(
i
)
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