Panda3D
|
A listing of files within multifiles for management of client-side synchronization with a server-provided set of files. More...
#include "downloadDb.h"
Classes | |
class | Db |
class | FileRecord |
class | MultifileRecord |
Public Types | |
typedef pvector< PT(FileRecord) > | FileRecords |
typedef pvector< PT(MultifileRecord) > | MultifileRecords |
enum | Status { Status_incomplete = 0, Status_complete = 1, Status_decompressed = 2, Status_extracted = 3 } |
typedef pvector< HashVal > | VectorHash |
typedef pmap< Filename, VectorHash > | VersionMap |
Public Member Functions | |
DownloadDb () | |
Primarily used for testing. More... | |
DownloadDb (Ramfile &server_file, Filename &client_file) | |
Create a download db with these client and server dbs. More... | |
DownloadDb (Filename &server_file, Filename &client_file) | |
Create a download db with these client and server dbs. More... | |
void | add_client_multifile (string server_mfname) |
void | add_version (const Filename &name, const HashVal &hash, int version) |
Appends a new version of the file onto the end of the list, or changes the hash associated with a version previously added. More... | |
bool | client_multifile_complete (string mfname) const |
A multifile is complete when it is completely downloaded. More... | |
bool | client_multifile_decompressed (string mfname) const |
bool | client_multifile_exists (string mfname) const |
bool | client_multifile_extracted (string mfname) const |
void | create_new_server_db () |
Used on the server side makefiles to create a new clean server db. More... | |
void | delete_client_multifile (string mfname) |
void | expand_client_multifile (string mfname) |
HashVal | get_client_multifile_hash (string mfname) const |
Return the hash value of the file we are working on. More... | |
string | get_client_multifile_name (int index) const |
Phase | get_client_multifile_phase (string mfname) const |
int | get_client_multifile_size (string mfname) const |
int | get_client_num_multifiles () const |
const HashVal & | get_hash (const Filename &name, int version) const |
Returns the MD5 hash associated with the indicated version of the indicated file. More... | |
int | get_num_versions (const Filename &name) const |
Returns the number of versions stored for the indicated file. More... | |
string | get_server_file_name (string mfname, int index) const |
HashVal | get_server_multifile_hash (string mfname) const |
Return the hash value of the server file. More... | |
string | get_server_multifile_name (int index) const |
Phase | get_server_multifile_phase (string mfname) const |
int | get_server_multifile_size (string mfname) const |
int | get_server_num_files (string mfname) const |
int | get_server_num_multifiles () const |
int | get_version (const Filename &name, const HashVal &hash) const |
Returns the version number of this particular file, determined by looking up the hash generated from the file. More... | |
bool | has_version (const Filename &name) const |
Returns true if the indicated file has version information, false otherwise. More... | |
void | insert_new_version (const Filename &name, const HashVal &hash) |
Inserts a new version 1 copy of the file, sliding all the other versions up by one. More... | |
void | output (ostream &out) const |
Db | read_db (Filename &file, bool want_server_info) |
Db | read_db (Ramfile &file, bool want_server_info) |
void | server_add_file (string mfname, string fname) |
void | server_add_multifile (string mfname, Phase phase, int size, int status) |
void | set_client_multifile_complete (string mfname) |
void | set_client_multifile_decompressed (string mfname) |
int | set_client_multifile_delta_size (string mfname, int size) |
void | set_client_multifile_extracted (string mfname) |
void | set_client_multifile_hash (string mfname, HashVal val) |
Set the hash value of file we are working on. More... | |
void | set_client_multifile_incomplete (string mfname) |
void | set_client_multifile_size (string mfname, int size) |
void | set_num_versions (const Filename &name, int num_versions) |
Reduces the number of versions of a particular file stored in the ddb by throwing away all versions higher than the indicated index. More... | |
void | set_server_multifile_hash (string mfname, HashVal val) |
Set the hash value of file we are working on. More... | |
void | set_server_multifile_size (string mfname, int size) |
void | write (ostream &out) const |
bool | write_client_db (Filename &file) |
bool | write_db (Filename &file, Db db, bool want_server_info) |
bool | write_server_db (Filename &file) |
void | write_version_map (ostream &out) const |
Public Attributes | |
Db | _client_db |
Db | _server_db |
Static Public Attributes | |
static PN_uint32 | _bogus_magic_number = 0x11111111 |
static PN_uint32 | _magic_number = 0xfeedfeed |
A listing of files within multifiles for management of client-side synchronization with a server-provided set of files.
This class manages one copy of the database for the client, representing the files on the client system, and another copy for the server, representing the files the server has available.
Definition at line 67 of file downloadDb.h.
DownloadDb::DownloadDb | ( | ) |
Primarily used for testing.
Definition at line 89 of file downloadDb.cxx.
References client_multifile_complete().
Referenced by DownloadDb().
Create a download db with these client and server dbs.
Definition at line 58 of file downloadDb.cxx.
References DownloadDb().
Create a download db with these client and server dbs.
Definition at line 73 of file downloadDb.cxx.
References DownloadDb().
Appends a new version of the file onto the end of the list, or changes the hash associated with a version previously added.
Note: version numbers start at 1
Definition at line 1070 of file downloadDb.cxx.
References insert_new_version().
Referenced by get_hash(), and DownloadDb::Db::write_header().
bool DownloadDb::client_multifile_complete | ( | string | mfname | ) | const |
A multifile is complete when it is completely downloaded.
Note: it may already be decompressed or extracted and it is still complete
Definition at line 178 of file downloadDb.cxx.
References get_client_multifile_hash().
Referenced by DownloadDb().
void DownloadDb::create_new_server_db | ( | ) |
Used on the server side makefiles to create a new clean server db.
Definition at line 399 of file downloadDb.cxx.
References DownloadDb::Db::parse_header().
Referenced by set_server_multifile_hash().
HashVal DownloadDb::get_client_multifile_hash | ( | string | mfname | ) | const |
Return the hash value of the file we are working on.
Definition at line 212 of file downloadDb.cxx.
References get_server_multifile_hash().
Referenced by client_multifile_complete().
Returns the MD5 hash associated with the indicated version of the indicated file.
Definition at line 1182 of file downloadDb.cxx.
References StreamWriter::add_int32(), add_version(), StreamWriter::append_data(), HashVal::as_dec(), StreamReader::extract_bytes(), StreamReader::get_int32(), and StreamReader::get_istream().
Referenced by get_version().
int DownloadDb::get_num_versions | ( | const Filename & | name | ) | const |
Returns the number of versions stored for the indicated file.
Definition at line 1120 of file downloadDb.cxx.
References set_num_versions().
Referenced by has_version().
HashVal DownloadDb::get_server_multifile_hash | ( | string | mfname | ) | const |
Return the hash value of the server file.
Definition at line 223 of file downloadDb.cxx.
References set_client_multifile_hash().
Referenced by get_client_multifile_hash().
Returns the version number of this particular file, determined by looking up the hash generated from the file.
Returns -1 if the version number cannot be determined.
Definition at line 1159 of file downloadDb.cxx.
References get_hash().
Referenced by set_num_versions().
bool DownloadDb::has_version | ( | const Filename & | name | ) | const |
Returns true if the indicated file has version information, false otherwise.
Some files recorded in the database may not bother to track versions.
Definition at line 1109 of file downloadDb.cxx.
References get_num_versions().
Referenced by insert_new_version().
Inserts a new version 1 copy of the file, sliding all the other versions up by one.
Definition at line 1096 of file downloadDb.cxx.
References has_version().
Referenced by add_version().
void DownloadDb::set_client_multifile_hash | ( | string | mfname, |
HashVal | val | ||
) |
Set the hash value of file we are working on.
Definition at line 234 of file downloadDb.cxx.
References set_server_multifile_hash().
Referenced by get_server_multifile_hash().
void DownloadDb::set_num_versions | ( | const Filename & | name, |
int | num_versions | ||
) |
Reduces the number of versions of a particular file stored in the ddb by throwing away all versions higher than the indicated index.
Definition at line 1137 of file downloadDb.cxx.
References get_version().
Referenced by get_num_versions().
void DownloadDb::set_server_multifile_hash | ( | string | mfname, |
HashVal | val | ||
) |
Set the hash value of file we are working on.
Definition at line 246 of file downloadDb.cxx.
References VirtualFileSystem::close_read_file(), create_new_server_db(), VirtualFileSystem::get_global_ptr(), VirtualFileSystem::open_read_file(), Filename::open_write(), Filename::set_binary(), DownloadDb::Db::write_bogus_header(), and DownloadDb::Db::write_header().
Referenced by set_client_multifile_hash().