MCPcopy Create free account
hub / github.com/amule-project/amule / LoadSourceSeeds

Method LoadSourceSeeds

src/PartFile.cpp:1156–1241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1154}
1155
1156void CPartFile::LoadSourceSeeds()
1157{
1158 CMemFile sources_data;
1159
1160 bool valid_sources = false;
1161
1162 const CPath seedsPath = m_fullname.AppendExt(".seeds");
1163 if (!seedsPath.FileExists()) {
1164 return;
1165 }
1166
1167 CFile file(seedsPath, CFile::read);
1168 if (!file.IsOpened()) {
1169 // Exists but can't be opened. Should not happen. Probably permission problem, try to remove it.
1170 AddLogLineN(CFormat( _("Can't read seeds file for Partfile %s (%s)") )
1171 % m_partmetfilename
1172 % GetFileName() );
1173 CPath::RemoveFile(seedsPath);
1174 return;
1175 }
1176
1177 bool badSeedsFile = false;
1178 try {
1179 uint8 src_count = file.ReadUInt8();
1180
1181 bool bUseSX2Format = (src_count == 0);
1182
1183 if (bUseSX2Format) {
1184 // v3 sources seeds
1185 src_count = file.ReadUInt8();
1186 }
1187
1188 sources_data.WriteUInt16(src_count);
1189
1190 for (int i = 0; i< src_count; ++i) {
1191 uint32 dwID = file.ReadUInt32();
1192 uint16 nPort = file.ReadUInt16();
1193
1194 sources_data.WriteUInt32(bUseSX2Format ? dwID : wxUINT32_SWAP_ALWAYS(dwID));
1195 sources_data.WriteUInt16(nPort);
1196 sources_data.WriteUInt32(0);
1197 sources_data.WriteUInt16(0);
1198
1199 if (bUseSX2Format) {
1200 sources_data.WriteHash(file.ReadHash());
1201 sources_data.WriteUInt8(file.ReadUInt8());
1202 }
1203
1204 }
1205
1206 if (!file.Eof()) {
1207
1208 // v2: Added to keep track of too old seeds
1209 time_t timeFromFile = (time_t)file.ReadUInt32();
1210
1211 // Time frame is 2 hours. More than enough to compile
1212 // your new aMule version!.
1213 if ((timeFromFile + MIN2S(120)) >= (uint32) time(NULL)) {

Callers 1

OnIPFilterEventMethod · 0.45

Calls 15

CFormatClass · 0.85
AppendExtMethod · 0.80
FileExistsMethod · 0.80
ReadUInt8Method · 0.80
WriteUInt16Method · 0.80
ReadUInt32Method · 0.80
ReadUInt16Method · 0.80
WriteUInt32Method · 0.80
WriteUInt8Method · 0.80
SeekMethod · 0.80
whatMethod · 0.80
IsOpenedMethod · 0.45

Tested by

no test coverage detected