linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05171
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2805: fix mix-ups between partial & full lists when both are available
------------------------------------------------------------
revno: 2805
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2012-01-08 17:28:26 +0100
message:
fix mix-ups between partial & full lists when both are available
modified:
dcpp/DirectoryListing.cpp
dcpp/DirectoryListing.h
win32/DirectoryListingFrame.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/DirectoryListing.cpp'
--- dcpp/DirectoryListing.cpp 2012-01-07 16:20:01 +0000
+++ dcpp/DirectoryListing.cpp 2012-01-08 16:28:26 +0000
@@ -31,10 +31,6 @@
#include "StringTokenizer.h"
#include "version.h"
-#ifdef ff
-#undef ff
-#endif
-
namespace dcpp {
DirectoryListing::DirectoryListing(const HintedUser& aUser) :
@@ -80,18 +76,32 @@
return ClientManager::getInstance()->getUser(cid);
}
-void DirectoryListing::loadFile(const string& name) {
- string txt;
+void DirectoryListing::loadFile(const string& path) {
+ string actualPath;
+ if(dcpp::File::getSize(path + ".bz2") != -1) {
+ actualPath = path + ".bz2";
+ }
// For now, we detect type by ending...
- string ext = Util::getFileExt(name);
-
- dcpp::File ff(name, dcpp::File::READ, dcpp::File::OPEN);
- if(Util::stricmp(ext, ".bz2") == 0) {
- FilteredInputStream<UnBZFilter, false> f(&ff);
- loadXML(f, false);
- } else if(Util::stricmp(ext, ".xml") == 0) {
- loadXML(ff, false);
+ auto ext = Util::getFileExt(actualPath.empty() ? path : actualPath);
+
+ {
+ dcpp::File file(actualPath.empty() ? path : actualPath, dcpp::File::READ, dcpp::File::OPEN);
+
+ if(Util::stricmp(ext, ".bz2") == 0) {
+ FilteredInputStream<UnBZFilter, false> f(&file);
+ loadXML(f, false);
+ } else if(Util::stricmp(ext, ".xml") == 0) {
+ loadXML(file, false);
+ } else {
+ throw Exception(_("Invalid file list extension (must be .xml or .bz2)"));
+ }
+ }
+
+ if(!actualPath.empty()) {
+ // save the uncompressed file.
+ save(path);
+ dcpp::File::deleteFile(actualPath);
}
}
=== modified file 'dcpp/DirectoryListing.h'
--- dcpp/DirectoryListing.h 2012-01-06 23:14:39 +0000
+++ dcpp/DirectoryListing.h 2012-01-08 16:28:26 +0000
@@ -127,7 +127,7 @@
DirectoryListing(const HintedUser& aUser);
~DirectoryListing();
- void loadFile(const string& name);
+ void loadFile(const string& path);
string updateXML(const std::string&);
string loadXML(InputStream& xml, bool updating);
=== modified file 'win32/DirectoryListingFrame.cpp'
--- win32/DirectoryListingFrame.cpp 2012-01-08 14:35:15 +0000
+++ win32/DirectoryListingFrame.cpp 2012-01-08 16:28:26 +0000
@@ -116,7 +116,16 @@
void DirectoryListingFrame::openWindow_(TabViewPtr parent, const tstring& aFile, const tstring& aDir, const HintedUser& aUser, int64_t aSpeed, Activation activate) {
DirectoryListingFrame* frame = new DirectoryListingFrame(parent, aUser, aSpeed);
- frame->path = Text::fromT(aFile);
+
+ /* save the path now in case the tab is closed without having been loaded (the file list will
+ only be loaded upon tab activation), to still have it in WindowManager. */
+ auto& path = frame->path;
+ path = Text::fromT(aFile);
+ auto n = path.size();
+ if(n > 4 && Util::stricmp(path.substr(n - 4), ".bz2") == 0) {
+ // strip the .bz2 ext - the file list loader will now where to find the file list anyway.
+ path.erase(n - 4);
+ }
if(activate == FORCE_ACTIVE || (activate == FOLLOW_SETTING && !BOOLSETTING(POPUNDER_FILELIST))) {
frame->loadFile(aDir);
@@ -528,6 +537,8 @@
selectItem(Text::toT(sel));
}
+ status->setText(STATUS_STATUS, T_("Partial file list loaded"));
+
} catch(const Exception& e) {
error = Text::toT(e.getError());
updateTitle();