Low-level writing of files.
Control the low-level management of files in the download. Contains
functions to open and close, read and write, enable and disable, flush
and delete, all the files in the download. Also serves as an abstraction
layer, as the reading and writing is called with no knowledge of file
boundaries.
|
|
__init__(self,
files,
piece_lengths,
doneflag,
config,
enabled_files=None)
Initializes the Storage. |
source code
|
|
|
|
|
|
|
|
boolean
|
|
|
|
|
|
|
sync(self)
Synchronize all read/write files to disk. |
source code
|
|
|
|
|
long
|
|
file handle
|
|
|
|
|
|
|
|
file handle
|
|
|
|
_reset_ranges(self)
Re-initialize the ranges from the working copies. |
source code
|
|
(long, long, long,
string)
|
|
list of tuple of (string,
long, long)
|
|
|
DebTorrent.piecebuffer.SingleBuffer
|
read(self,
pos,
amount,
flush_first=True)
Read data from the download. |
source code
|
|
|
|
|
|
|
|
|
|
top_off(self)
Extend all files to their appropriate length. |
source code
|
|
|
|
|
|
|
|
tuple
|
|
|
|
|
|
|
|
|
|
|
list of int
|
|
|
|
|
dictionary
|
pickle(self)
Create a dictionary representing the current state of the
download. |
source code
|
|
list of int
|
unpickle(self,
data)
Extract the current status of the download from a pickled
dictionary. |
source code
|
|
|
|
reset_file_status(self)
a shortcut to the _reset_ranges method |
source code
|
|
list of long
|
begins
the offset within the download that each non-disabled file begins
at
|
string
|
bufferdir
the buffer directory
|
list of boolean
|
disabled
list of true for the files that are disabled
|
list of tuple
|
disabled_ranges
for each file, a tuple containing the working range, shared
pieces, and disabled range (see _get_disabled_ranges for their meaning)
|
threading.Event
|
doneflag
the flag that indicates when the program is to be shutdown
|
list of (int, int)
|
file_pieces
for each file, the starting and ending piece of the file
|
list of (long, long,
long, string)
|
file_ranges
for each file, the start offset within the download, end offset,
offset within the file, and file name
|
list of tuple of (string,
long)
|
files
the files list from the info of the metainfo dictionary
|
list
|
handlebuffer
the list of open files, in the order of most recently accessed,
with the most recently accessed at the end of the list (only if there
is a limit on the number of open files, otherwise None)
|
dictionary of {string, file
handle}
|
handles
the file handles that are open, keys are file names and values are
the file handles
|
lock
|
lock
a threading lock object for synchorizing threads (semaphore)
|
method
|
lock_file
locks a file (if file locking is enabled, otherwise does
nothing)
|
boolean
|
lock_while_reading
whether to lock files while reading them
|
int
|
max_files_open
the maximum number of files to have open at a time (0 means no
maximum)
|
dictionary of {string,
long}
|
mtimes
the last modified time of each file (by name)
|
dictionary
|
piece_files
for each piece, the starting and ending offset of the piece in the
file, the length of the file, and the file name
|
list of long
|
piece_lengths
the list of piece lengths
|
list of list of (long,
long, long, string)
|
ranges
for each file, the list of files to be written when writing to
that file (may not be the actual file, i.e if it is disabled)
|
dictionary of {string,
long}
|
sizes
the desired length of each file (by name)
|
dictionary of {string,
long}
|
tops
the current length of each file (by name)
|
long
|
total_length
the total length in bytes of the download
|
method
|
unlock_file
unlocks a file (if file locking is enabled, otherwise does
nothing)
|
dictionary of {string,
int}
|
whandles
the files that are open for writing, keys are the file names and
values are all 1
|
list of list of (long,
long, long, string)
|
working_ranges
For each file, the list of files to be written when writing to
that file (may not be the actual file, i.e if it is disabled).
|