Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
erp5
Commits
dff53681
Commit
dff53681
authored
Jun 04, 2012
by
Romain Courteaud
Committed by
Sebastien Robin
Aug 07, 2014
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get modification date from btree.
Support no content.
parent
00f696ee
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
+23
-12
product/ERP5/Document/BigFile.py
product/ERP5/Document/BigFile.py
+23
-12
No files found.
product/ERP5/Document/BigFile.py
View file @
dff53681
...
@@ -123,6 +123,8 @@ class BigFile(File):
...
@@ -123,6 +123,8 @@ class BigFile(File):
if
range
is
not
None
:
if
range
is
not
None
:
ranges
=
HTTPRangeSupport
.
parseRange
(
range
)
ranges
=
HTTPRangeSupport
.
parseRange
(
range
)
data
=
self
.
_baseGetData
()
if
if_range
is
not
None
:
if
if_range
is
not
None
:
# Only send ranges if the data isn't modified, otherwise send
# Only send ranges if the data isn't modified, otherwise send
# the whole object. Support both ETags and Last-Modified dates!
# the whole object. Support both ETags and Last-Modified dates!
...
@@ -139,6 +141,9 @@ class BigFile(File):
...
@@ -139,6 +141,9 @@ class BigFile(File):
try
:
mod_since
=
long
(
DateTime
(
date
).
timeTime
())
try
:
mod_since
=
long
(
DateTime
(
date
).
timeTime
())
except
:
mod_since
=
None
except
:
mod_since
=
None
if
mod_since
is
not
None
:
if
mod_since
is
not
None
:
if
data
is
not
None
:
last_mod
=
long
(
data
.
_p_mtime
)
else
:
if
self
.
_p_mtime
:
if
self
.
_p_mtime
:
last_mod
=
long
(
self
.
_p_mtime
)
last_mod
=
long
(
self
.
_p_mtime
)
else
:
else
:
...
@@ -161,8 +166,10 @@ class BigFile(File):
...
@@ -161,8 +166,10 @@ class BigFile(File):
RESPONSE
.
setHeader
(
'Content-Range'
,
RESPONSE
.
setHeader
(
'Content-Range'
,
'bytes */%d'
%
self
.
getSize
())
'bytes */%d'
%
self
.
getSize
())
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
RESPONSE
.
setHeader
(
'Last-Modified'
,
if
data
is
not
None
:
rfc1123_date
(
self
.
_p_mtime
))
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
data
.
_p_mtime
))
else
:
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_p_mtime
))
RESPONSE
.
setHeader
(
'Content-Type'
,
self
.
content_type
)
RESPONSE
.
setHeader
(
'Content-Type'
,
self
.
content_type
)
RESPONSE
.
setHeader
(
'Content-Length'
,
self
.
getSize
())
RESPONSE
.
setHeader
(
'Content-Length'
,
self
.
getSize
())
RESPONSE
.
setStatus
(
416
)
RESPONSE
.
setStatus
(
416
)
...
@@ -175,8 +182,10 @@ class BigFile(File):
...
@@ -175,8 +182,10 @@ class BigFile(File):
start
,
end
=
ranges
[
0
]
start
,
end
=
ranges
[
0
]
size
=
end
-
start
size
=
end
-
start
RESPONSE
.
setHeader
(
'Last-Modified'
,
if
data
is
not
None
:
rfc1123_date
(
self
.
_p_mtime
))
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
data
.
_p_mtime
))
else
:
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_p_mtime
))
RESPONSE
.
setHeader
(
'Content-Type'
,
self
.
content_type
)
RESPONSE
.
setHeader
(
'Content-Type'
,
self
.
content_type
)
RESPONSE
.
setHeader
(
'Content-Length'
,
size
)
RESPONSE
.
setHeader
(
'Content-Length'
,
size
)
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
...
@@ -184,7 +193,6 @@ class BigFile(File):
...
@@ -184,7 +193,6 @@ class BigFile(File):
'bytes %d-%d/%d'
%
(
start
,
end
-
1
,
self
.
getSize
()))
'bytes %d-%d/%d'
%
(
start
,
end
-
1
,
self
.
getSize
()))
RESPONSE
.
setStatus
(
206
)
# Partial content
RESPONSE
.
setStatus
(
206
)
# Partial content
data
=
self
.
_baseGetData
()
if
isinstance
(
data
,
str
):
if
isinstance
(
data
,
str
):
RESPONSE
.
write
(
data
[
start
:
end
])
RESPONSE
.
write
(
data
[
start
:
end
])
return
True
return
True
...
@@ -209,6 +217,7 @@ class BigFile(File):
...
@@ -209,6 +217,7 @@ class BigFile(File):
size
=
(
size
+
len
(
'%d%d'
%
(
start
,
end
-
1
))
+
size
=
(
size
+
len
(
'%d%d'
%
(
start
,
end
-
1
))
+
end
-
start
)
end
-
start
)
data
=
self
.
_baseGetData
()
# Some clients implement an earlier draft of the spec, they
# Some clients implement an earlier draft of the spec, they
# will only accept x-byteranges.
# will only accept x-byteranges.
...
@@ -216,15 +225,15 @@ class BigFile(File):
...
@@ -216,15 +225,15 @@ class BigFile(File):
RESPONSE
.
setHeader
(
'Content-Length'
,
size
)
RESPONSE
.
setHeader
(
'Content-Length'
,
size
)
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
RESPONSE
.
setHeader
(
'Last-Modified'
,
if
data
is
not
None
:
rfc1123_date
(
self
.
_p_mtime
))
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
data
.
_p_mtime
))
else
:
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_p_mtime
))
RESPONSE
.
setHeader
(
'Content-Type'
,
RESPONSE
.
setHeader
(
'Content-Type'
,
'multipart/%sbyteranges; boundary=%s'
%
(
'multipart/%sbyteranges; boundary=%s'
%
(
draftprefix
,
boundary
))
draftprefix
,
boundary
))
RESPONSE
.
setStatus
(
206
)
# Partial content
RESPONSE
.
setStatus
(
206
)
# Partial content
data
=
self
.
_baseGetData
()
for
start
,
end
in
ranges
:
for
start
,
end
in
ranges
:
RESPONSE
.
write
(
'
\
r
\
n
--%s
\
r
\
n
'
%
boundary
)
RESPONSE
.
write
(
'
\
r
\
n
--%s
\
r
\
n
'
%
boundary
)
RESPONSE
.
write
(
'Content-Type: %s
\
r
\
n
'
%
RESPONSE
.
write
(
'Content-Type: %s
\
r
\
n
'
%
...
@@ -285,6 +294,8 @@ class BigFile(File):
...
@@ -285,6 +294,8 @@ class BigFile(File):
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
if
data
is
None
:
return
''
iterator
=
data
.
iterate
()
iterator
=
data
.
iterate
()
try
:
try
:
while
1
:
while
1
:
...
...
Kirill Smelkov
@kirr
mentioned in commit
4d8f0c33
·
Feb 27, 2015
mentioned in commit
4d8f0c33
mentioned in commit 4d8f0c3336b85da99c0ffc5a5fc35a6cf317b0c2
Toggle commit list
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