Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
70c02c4d
Commit
70c02c4d
authored
May 18, 2011
by
Antony Chazapis
Browse files
Fix account/container size reporting, zero-length object uploading.
parent
fb19cc80
Changes
2
Show whitespace changes
Inline
Side-by-side
pithos/api/functions.py
View file @
70c02c4d
...
@@ -423,8 +423,14 @@ def object_write(request, v_account, v_container, v_object):
...
@@ -423,8 +423,14 @@ def object_write(request, v_account, v_container, v_object):
if
'Content-Type'
not
in
meta
:
if
'Content-Type'
not
in
meta
:
raise
LengthRequired
(
'Missing Content-Type header'
)
raise
LengthRequired
(
'Missing Content-Type header'
)
sock
=
raw_input_socket
(
request
)
md5
=
hashlib
.
md5
()
md5
=
hashlib
.
md5
()
if
content_length
==
0
:
try
:
backend
.
update_object
(
request
.
user
,
v_container
,
v_object
,
''
)
except
NameError
:
raise
ItemNotFound
(
'Container does not exist'
)
else
:
sock
=
raw_input_socket
(
request
)
offset
=
0
offset
=
0
for
data
in
socket_read_iterator
(
sock
,
content_length
):
for
data
in
socket_read_iterator
(
sock
,
content_length
):
# TODO: Raise 408 (Request Timeout) if this takes too long.
# TODO: Raise 408 (Request Timeout) if this takes too long.
...
@@ -433,7 +439,7 @@ def object_write(request, v_account, v_container, v_object):
...
@@ -433,7 +439,7 @@ def object_write(request, v_account, v_container, v_object):
try
:
try
:
backend
.
update_object
(
request
.
user
,
v_container
,
v_object
,
data
,
offset
)
backend
.
update_object
(
request
.
user
,
v_container
,
v_object
,
data
,
offset
)
except
NameError
:
except
NameError
:
raise
ItemNotFound
(
'
Object
does not exist'
)
raise
ItemNotFound
(
'
Container
does not exist'
)
offset
+=
len
(
data
)
offset
+=
len
(
data
)
meta
[
'hash'
]
=
md5
.
hexdigest
().
lower
()
meta
[
'hash'
]
=
md5
.
hexdigest
().
lower
()
...
...
pithos/backends/simple.py
View file @
70c02c4d
...
@@ -38,7 +38,9 @@ class SimpleBackend(BaseBackend):
...
@@ -38,7 +38,9 @@ class SimpleBackend(BaseBackend):
return
{
'name'
:
account
,
'count'
:
0
,
'bytes'
:
0
}
return
{
'name'
:
account
,
'count'
:
0
,
'bytes'
:
0
}
contents
=
os
.
listdir
(
fullname
)
contents
=
os
.
listdir
(
fullname
)
count
=
len
(
contents
)
count
=
len
(
contents
)
size
=
sum
((
os
.
path
.
getsize
(
os
.
path
.
join
(
fullname
,
x
))
for
x
in
os
.
listdir
(
fullname
)))
size
=
0
for
y
in
(
os
.
path
.
join
(
fullname
,
z
)
for
z
in
contents
):
size
+=
sum
((
os
.
path
.
getsize
(
os
.
path
.
join
(
y
,
x
))
for
x
in
os
.
listdir
(
y
)))
meta
=
self
.
_get_metadata
(
account
)
meta
=
self
.
_get_metadata
(
account
)
meta
.
update
({
'name'
:
account
,
'count'
:
count
,
'bytes'
:
size
})
meta
.
update
({
'name'
:
account
,
'count'
:
count
,
'bytes'
:
size
})
return
meta
return
meta
...
@@ -81,7 +83,7 @@ class SimpleBackend(BaseBackend):
...
@@ -81,7 +83,7 @@ class SimpleBackend(BaseBackend):
fullname
=
self
.
_get_containerinfo
(
account
,
name
)
fullname
=
self
.
_get_containerinfo
(
account
,
name
)
contents
=
os
.
listdir
(
fullname
)
contents
=
os
.
listdir
(
fullname
)
count
=
len
(
contents
)
count
=
len
(
contents
)
size
=
os
.
stat
(
fullname
).
st_size
size
=
sum
((
os
.
path
.
getsize
(
os
.
path
.
join
(
fullname
,
x
))
for
x
in
contents
))
meta
=
self
.
_get_metadata
(
os
.
path
.
join
(
account
,
name
))
meta
=
self
.
_get_metadata
(
os
.
path
.
join
(
account
,
name
))
meta
.
update
({
'name'
:
name
,
'count'
:
count
,
'bytes'
:
size
})
meta
.
update
({
'name'
:
name
,
'count'
:
count
,
'bytes'
:
size
})
return
meta
return
meta
...
...
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