*** empty log message ***

This commit is contained in:
Joe Shochet 2000-12-14 21:39:34 +00:00
parent 09915168d3
commit e6abe76f7d
4 changed files with 29 additions and 206 deletions

View File

@ -44,39 +44,6 @@ get_server_multifile_name(int index) const {
return _server_db.get_multifile_name(index);
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE Version DownloadDb::
get_client_multifile_version(string mfname) const {
return (_client_db.get_multifile_record_named(mfname))->_version;
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DownloadDb::
set_client_multifile_version(string mfname, Version version) {
(_client_db.get_multifile_record_named(mfname))->_version = version;
write_db(_client_db._filename, _client_db);
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE Version DownloadDb::
get_server_multifile_version(string mfname) const {
return (_server_db.get_multifile_record_named(mfname))->_version;
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
@ -198,8 +165,8 @@ set_client_multifile_decompressed(string mfname) {
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DownloadDb::
set_client_multifile_expanded(string mfname) {
(_client_db.get_multifile_record_named(mfname))->_status = Status_expanded;
set_client_multifile_extracted(string mfname) {
(_client_db.get_multifile_record_named(mfname))->_status = Status_extracted;
write_db(_client_db._filename, _client_db);
}
@ -242,57 +209,3 @@ INLINE string DownloadDb::
get_server_file_name(string mfname, int index) const {
return (_server_db.get_multifile_record_named(mfname))->get_file_name(index);
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE Version DownloadDb::
get_client_file_version(string mfname, string fname) const {
return ((_client_db.get_multifile_record_named(mfname))->get_file_record_named(fname))->_version;
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE Version DownloadDb::
get_server_file_version(string mfname, string fname) const {
return ((_server_db.get_multifile_record_named(mfname))->get_file_record_named(fname))->_version;
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DownloadDb::
set_client_file_version(string mfname, string fname, Version version) {
((_client_db.get_multifile_record_named(mfname))->get_file_record_named(fname))->_version = version;
write_db(_client_db._filename, _client_db);
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE HashVal DownloadDb::
get_client_file_hash(string mfname, string fname) const {
return ((_client_db.get_multifile_record_named(mfname))->get_file_record_named(fname))->_hash;
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE HashVal DownloadDb::
get_server_file_hash(string mfname, string fname) const {
return ((_server_db.get_multifile_record_named(mfname))->get_file_record_named(fname))->_hash;
}

View File

@ -93,16 +93,6 @@ write_server_db(Filename &file) {
return write_db(file, _server_db);
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
bool DownloadDb::
client_db_current_version(void) const {
return (_client_db._version == _server_db._version);
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
@ -118,7 +108,7 @@ client_multifile_exists(string mfname) const {
// Access: Public
// Description: A multifile is complete when it is completely
// downloaded. Note: it may already be decompressed
// or expanded and it is still complete
// or extracted and it is still complete
////////////////////////////////////////////////////////////////////
bool DownloadDb::
client_multifile_complete(string mfname) const {
@ -143,45 +133,9 @@ client_multifile_decompressed(string mfname) const {
// Description:
////////////////////////////////////////////////////////////////////
bool DownloadDb::
client_multifile_expanded(string mfname) const {
client_multifile_extracted(string mfname) const {
int client_status = _client_db.get_multifile_record_named(mfname)->_status;
return (client_status >= Status_expanded);
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
bool DownloadDb::
client_multifile_version_correct(string mfname) const {
Version client_version = get_client_multifile_version(mfname);
Version server_version = get_server_multifile_version(mfname);
return (client_version == server_version);
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
bool DownloadDb::
client_file_version_correct(string mfname, string filename) const {
Version client_version = get_client_file_version(mfname, filename);
Version server_version = get_server_file_version(mfname, filename);
return (client_version == server_version);
}
////////////////////////////////////////////////////////////////////
// Function: DownloadDb::
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
bool DownloadDb::
client_file_hash_correct(string mfname, string filename) const {
HashVal client_hash = get_client_file_hash(mfname, filename);
HashVal server_hash = get_server_file_hash(mfname, filename);
return (client_hash == server_hash);
return (client_status >= Status_extracted);
}
// Operations on multifiles
@ -206,7 +160,6 @@ add_client_multifile(string server_mfname) {
PT(MultifileRecord) client_mfr = new MultifileRecord;
client_mfr->_name = server_mfr->_name;
client_mfr->_phase = server_mfr->_phase;
client_mfr->_version = server_mfr->_version;
_client_db.add_multifile_record(client_mfr);
}
@ -300,8 +253,8 @@ create_new_server_db(void) {
// Description:
////////////////////////////////////////////////////////////////////
void DownloadDb::
server_add_multifile(string mfname, Phase phase, Version version, int size, int status) {
PT(MultifileRecord) mfr = new MultifileRecord(mfname, phase, version, size, status);
server_add_multifile(string mfname, Phase phase, int size, int status) {
PT(MultifileRecord) mfr = new MultifileRecord(mfname, phase, size, status);
_server_db.add_multifile_record(mfr);
}
@ -312,9 +265,9 @@ server_add_multifile(string mfname, Phase phase, Version version, int size, int
// Description:
////////////////////////////////////////////////////////////////////
void DownloadDb::
server_add_file(string mfname, string fname, Version version, HashVal hash) {
server_add_file(string mfname, string fname) {
// Make the new file record
PT(FileRecord) fr = new FileRecord(fname, version, hash);
PT(FileRecord) fr = new FileRecord(fname);
// Find the multifile with mfname
vector<PT(MultifileRecord)>::iterator i = _server_db._mfile_records.begin();
@ -346,7 +299,6 @@ DownloadDb::MultifileRecord::
MultifileRecord(void) {
_name = "";
_phase = 0;
_version = 0;
_size = 0;
_status = Status_incomplete;
}
@ -358,10 +310,9 @@ MultifileRecord(void) {
// Description:
////////////////////////////////////////////////////////////////////
DownloadDb::MultifileRecord::
MultifileRecord(string name, Phase phase, Version version, int size, int status) {
MultifileRecord(string name, Phase phase, int size, int status) {
_name = name;
_phase = phase;
_version = version;
_size = size;
_status = status;
}
@ -377,7 +328,6 @@ output(ostream &out) const {
out << "==================================================" << endl;
out << "MultifileRecord: " << _name << endl
<< " phase: " << _phase << endl
<< " version: " << _version << endl
<< " size: " << _size << endl
<< " status: " << _status << endl;
out << "--------------------------------------------------" << endl;
@ -631,14 +581,13 @@ parse_mfr(uchar *start, int size) {
PN_int32 mfr_name_length = di.get_int32();
mfr->_name = di.extract_bytes(mfr_name_length);
mfr->_phase = di.get_int32();
mfr->_version = di.get_int32();
mfr->_size = di.get_int32();
mfr->_status = di.get_int32();
mfr->_num_files = di.get_int32();
downloader_cat.debug()
<< "Parsed multifile record: " << mfr->_name << " phase: " << mfr->_phase
<< " version: " << mfr->_version << " size: " << mfr->_size
<< " size: " << mfr->_size
<< " status: " << mfr->_status << " num_files: " << mfr->_num_files << endl;
// Return the new MultifileRecord
@ -664,13 +613,9 @@ parse_fr(uchar *start, int size) {
DatagramIterator di(_datagram);
PN_int32 fr_name_length = di.get_int32();
fr->_name = di.extract_bytes(fr_name_length);
fr->_version = di.get_int32();
downloader_cat.spam()
<< "Parsed file record: " << fr->_name
<< " version: " << fr->_version
<< " hash: " << fr->_hash
<< endl;
<< "Parsed file record: " << fr->_name << endl;
// Return the new MultifileRecord
return fr;
@ -782,7 +727,6 @@ write(ofstream &write_stream) {
// Declare these outside the loop so we do not keep creating
// and deleting them
PN_int32 phase;
PN_int32 version;
PN_int32 size;
PN_int32 status;
PN_int32 num_files;
@ -796,7 +740,6 @@ write(ofstream &write_stream) {
// Cache some properties so we do not have to keep asking for them
phase = (*i)->_phase;
version = (*i)->_version;
size = (*i)->_size;
status = (*i)->_status;
num_files = (*i)->get_num_files();
@ -807,7 +750,7 @@ write(ofstream &write_stream) {
sizeof(header_length) + // Size of this header length
sizeof(name_length) + // Size of the size of the name string
(*i)->_name.length() + // Size of the name string
sizeof(phase) + sizeof(version) + sizeof(size) +
sizeof(phase) + sizeof(size) +
sizeof(status) + sizeof(num_files);
// Add the length of this entire datagram
@ -820,7 +763,6 @@ write(ofstream &write_stream) {
// Add all the properties
_datagram.add_int32(phase);
_datagram.add_int32(version);
_datagram.add_int32(size);
_datagram.add_int32(status);
_datagram.add_int32(num_files);
@ -836,15 +778,13 @@ write(ofstream &write_stream) {
// Clear the datagram before we jam a bunch of stuff on it
_datagram.clear();
version = (*j)->_version;
name_length = (*j)->_name.length();
// Compute the length of this datagram
header_length =
sizeof(header_length) + // Size of this header length
sizeof(name_length) + // Size of the size of the name string
(*j)->_name.length() + // Size of the name string
sizeof(version);
(*j)->_name.length(); // Size of the name string
// Add the length of this entire datagram
_datagram.add_int32(header_length);
@ -854,9 +794,6 @@ write(ofstream &write_stream) {
// Add the name
_datagram.append_data((*j)->_name.c_str(), (*j)->_name.length());
// Add all the properties
_datagram.add_int32(version);
// Now put this datagram on the write stream
string msg = _datagram.get_message();
write_stream.write(msg.data(), msg.length());
@ -907,8 +844,6 @@ write_header(ofstream &write_stream) {
DownloadDb::FileRecord::
FileRecord(void) {
_name = "";
_version = 0;
_hash = HashVal();
}
@ -918,10 +853,8 @@ FileRecord(void) {
// Description:
////////////////////////////////////////////////////////////////////
DownloadDb::FileRecord::
FileRecord(string name, Version version, HashVal hash) {
FileRecord(string name) {
_name = name;
_version = version;
_hash = hash;
}
////////////////////////////////////////////////////////////////////
@ -931,10 +864,7 @@ FileRecord(string name, Version version, HashVal hash) {
////////////////////////////////////////////////////////////////////
void DownloadDb::FileRecord::
output(ostream &out) const {
out << " FileRecord: " << _name
<< " version: " << _version
<< " hash: " << _hash
<< endl;
out << " FileRecord: " << _name << endl;
}
////////////////////////////////////////////////////////////////////
@ -954,9 +884,10 @@ add_version(const Filename &name, HashVal hash, Version version) {
////////////////////////////////////////////////////////////////////
void DownloadDb::
add_version(const string &name, HashVal hash, Version version) {
nassertv(version >= 1);
// Try to find this name in the map
VersionMap::iterator i = _versions.find(name);
nassertv(version >= 1);
// If we did not find it, put a new vectorHash at this name_code
if (i == _versions.end()) {
@ -967,8 +898,8 @@ add_version(const string &name, HashVal hash, Version version) {
} else {
int size = (*i).second.size();
// Assert that this version is the next version in the list
nassertv(version<=size);
// Assert that this version is less than or equal to next version in the list
nassertv(version<=size+1);
// If you are overwriting an old hash value, just insert the new value
if (version-1 < size) {

View File

@ -49,12 +49,12 @@ PUBLISHED:
// Status of a multifile is stored in this enum
// Note these values are in increasing order of "doneness"
// So if you are decompressed, you are complete
// If you are expanded, you are decompressed and complete
// If you are extracted, you are decompressed and complete
enum Status {
Status_incomplete = 0,
Status_complete = 1,
Status_decompressed = 2,
Status_expanded = 3
Status_extracted = 3
};
DownloadDb(void);
@ -74,10 +74,6 @@ PUBLISHED:
INLINE string get_client_multifile_name(int index) const;
INLINE string get_server_multifile_name(int index) const;
INLINE Version get_client_multifile_version(string mfname) const;
INLINE void set_client_multifile_version(string mfname, Version version);
INLINE Version get_server_multifile_version(string mfname) const;
INLINE int get_client_multifile_size(string mfname) const;
INLINE void set_client_multifile_size(string mfname, int size);
INLINE int set_client_multifile_delta_size(string mfname, int size);
@ -90,32 +86,19 @@ PUBLISHED:
INLINE void set_client_multifile_incomplete(string mfname);
INLINE void set_client_multifile_complete(string mfname);
INLINE void set_client_multifile_decompressed(string mfname);
INLINE void set_client_multifile_expanded(string mfname);
INLINE void set_client_multifile_extracted(string mfname);
INLINE int get_client_num_files(string mfname) const;
INLINE int get_server_num_files(string mfname) const;
INLINE HashVal get_client_file_hash(string mfname, string fname) const;
INLINE HashVal get_server_file_hash(string mfname, string fname) const;
INLINE string get_client_file_name(string mfname, int index) const;
INLINE string get_server_file_name(string mfname, int index) const;
INLINE Version get_client_file_version(string mfname, string fname) const;
INLINE Version get_server_file_version(string mfname, string fname) const;
INLINE void set_client_file_version(string mfname, string fname, Version version);
// Check client db against server db
bool client_db_current_version(void) const;
// Queries from the Launcher
bool client_multifile_exists(string mfname) const;
bool client_multifile_complete(string mfname) const;
bool client_multifile_decompressed(string mfname) const;
bool client_multifile_expanded(string mfname) const;
bool client_multifile_version_correct(string mfname) const;
bool client_file_version_correct(string mfname, string filename) const;
bool client_file_hash_correct(string mfname, string filename) const;
bool client_multifile_extracted(string mfname) const;
// Operations on multifiles
void delete_client_multifile(string mfname);
@ -124,19 +107,17 @@ PUBLISHED:
// Server side operations to create multifile records
void create_new_server_db();
void server_add_multifile(string mfname, Phase phase, Version version, int size, int status);
void server_add_file(string mfname, string fname, Version version, HashVal hash);
void server_add_multifile(string mfname, Phase phase, int size, int status);
void server_add_file(string mfname, string fname);
public:
class EXPCL_PANDAEXPRESS FileRecord : public ReferenceCount {
public:
FileRecord(void);
FileRecord(string name, Version version, HashVal hash);
FileRecord(string name);
void output(ostream &out) const;
string _name;
Version _version;
HashVal _hash;
};
typedef vector<PT(FileRecord)> FileRecords;
@ -144,7 +125,7 @@ public:
class EXPCL_PANDAEXPRESS MultifileRecord : public ReferenceCount {
public:
MultifileRecord(void);
MultifileRecord(string name, Phase phase, Version version, int size, int status);
MultifileRecord(string name, Phase phase, int size, int status);
void output(ostream &out) const;
int get_num_files(void) const;
string get_file_name(int index) const;
@ -153,7 +134,6 @@ public:
void add_file_record(PT(FileRecord) fr);
string _name;
Phase _phase;
Version _version;
int _size;
int _status;
PN_int32 _num_files;
@ -177,7 +157,6 @@ public:
PT(FileRecord) parse_fr(uchar *start, int size);
bool read(ifstream &read_stream);
bool write(ofstream &write_stream);
Version _version;
Filename _filename;
MultifileRecords _mfile_records;
private:

View File

@ -638,6 +638,7 @@ DownloadStatus(char *buffer, int first_byte, int last_byte,
_first_byte = first_byte;
_last_byte = last_byte;
_total_bytes = total_bytes;
_total_bytes_written = 0;
_partial_content = partial_content;
reset();
}
@ -653,5 +654,4 @@ reset(void) {
_start = _buffer;
_next_in = _start;
_bytes_in_buffer = 0;
_total_bytes_written = 0;
}