mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-07 10:56:49 +00:00
Since we now require Python 2.5, we can use os.SEEK_END.
This commit is contained in:
parent
a1a1b5bf8a
commit
4ddcde3094
@ -1363,7 +1363,7 @@ class FileHandle(BaseUploadable):
|
||||
def get_size(self):
|
||||
if self._size is not None:
|
||||
return defer.succeed(self._size)
|
||||
self._filehandle.seek(0,2)
|
||||
self._filehandle.seek(0, os.SEEK_END)
|
||||
size = self._filehandle.tell()
|
||||
self._size = size
|
||||
self._filehandle.seek(0)
|
||||
|
@ -1224,7 +1224,7 @@ class MutableFileHandle:
|
||||
old_position = self._filehandle.tell()
|
||||
# Seek to the end of the file by seeking 0 bytes from the
|
||||
# file's end
|
||||
self._filehandle.seek(0, 2) # 2 == os.SEEK_END in 2.5+
|
||||
self._filehandle.seek(0, os.SEEK_END)
|
||||
self._size = self._filehandle.tell()
|
||||
# Restore the previous position, in case this was called
|
||||
# after a read.
|
||||
|
@ -1,4 +1,5 @@
|
||||
|
||||
import os
|
||||
from cStringIO import StringIO
|
||||
import urlparse, httplib
|
||||
import allmydata # for __full_version__
|
||||
@ -53,7 +54,7 @@ def do_http(method, url, body=""):
|
||||
c.putheader("Connection", "close")
|
||||
|
||||
old = body.tell()
|
||||
body.seek(0, 2)
|
||||
body.seek(0, os.SEEK_END)
|
||||
length = body.tell()
|
||||
body.seek(old)
|
||||
c.putheader("Content-Length", str(length))
|
||||
|
@ -437,7 +437,7 @@ class FileUtil(unittest.TestCase):
|
||||
f.write("stuff.")
|
||||
f.close()
|
||||
f = fileutil.open_or_create(fn)
|
||||
f.seek(0, 2)
|
||||
f.seek(0, os.SEEK_END)
|
||||
f.write("more.")
|
||||
f.close()
|
||||
f = open(fn, "r")
|
||||
|
Loading…
x
Reference in New Issue
Block a user