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

Method UpdateEncoders

src/ExternalConn.cpp:152–196  ·  view source on GitHub ↗

Check if encoder contains files that are no longer used or if we have new files without encoder yet.

Source from the content-addressed store, hash-verified

150// Check if encoder contains files that are no longer used
151// or if we have new files without encoder yet.
152void CFileEncoderMap::UpdateEncoders()
153{
154 IDSet curr_files, dead_files;
155 // Downloads
156 std::vector<CPartFile*> downloads;
157 theApp->downloadqueue->CopyFileList(downloads, true);
158 for (uint32 i = downloads.size(); i--;) {
159 uint32 id = downloads[i]->ECID();
160 curr_files.insert(id);
161 if (!count(id)) {
162 (*this)[id] = new CPartFile_Encoder(downloads[i]);
163 }
164 }
165 // Shares
166 std::vector<CKnownFile*> shares;
167 theApp->sharedfiles->CopyFileList(shares);
168 for (uint32 i = shares.size(); i--;) {
169 uint32 id = shares[i]->ECID();
170 // Check if it is already there.
171 // The curr_files.count(id) is enough, the IsCPartFile() is just a speedup.
172 if (shares[i]->IsCPartFile() && curr_files.count(id)) {
173 (*this)[id]->SetShared();
174 continue;
175 }
176 curr_files.insert(id);
177 if (!count(id)) {
178 (*this)[id] = new CKnownFile_Encoder(shares[i]);
179 }
180 }
181 // Check for removed files, and store them in a set for deletion.
182 // (std::map documentation is unclear if a construct like
183 // iterator to_del = it++; erase(to_del) ;
184 // works or invalidates it too.)
185 for (iterator it = begin(); it != end(); ++it) {
186 if (!curr_files.count(it->first)) {
187 dead_files.insert(it->first);
188 }
189 }
190 // then delete them
191 for (IDSet::iterator it = dead_files.begin(); it != dead_files.end(); ++it) {
192 iterator it2 = find(*it);
193 delete it2->second;
194 erase(it2);
195 }
196}
197
198
199//-------------------- CECServerSocket --------------------

Calls 8

ECIDMethod · 0.80
insertMethod · 0.80
CopyFileListMethod · 0.45
sizeMethod · 0.45
IsCPartFileMethod · 0.45
SetSharedMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected