linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #07950
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3398: Hub list caching fixed on Linux
------------------------------------------------------------
revno: 3398
committer: Fredrik Ullner <ullner@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Wed 2014-02-05 19:56:23 +0100
message:
Hub list caching fixed on Linux
modified:
changelog.txt
dcpp/FavoriteManager.cpp
dcpp/LogManager.cpp
dcpp/QueueManager.cpp
dcpp/Util.cpp
dcpp/Util.h
win32/DirectoryListingFrame.cpp
win32/FinishedFrameBase.h
win32/HubFrame.cpp
win32/MainWindow.cpp
win32/PrivateFrame.cpp
win32/SystemFrame.cpp
win32/WinUtil.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 'changelog.txt'
--- changelog.txt 2014-02-02 22:40:28 +0000
+++ changelog.txt 2014-02-05 18:56:23 +0000
@@ -14,6 +14,7 @@
* Add "/d <search>" for DuckDuckGo searches (poy)
* Add a dialog box to nag XP suckers into upgrading (poy)
* Support for a new XP-only branch in version checking (poy)
+* [L#395400] Hub list caching fixed on Linux (maksis, ullner)
-- 0.831 2013-11-11 --
* [L#1249810] Fix NMDC TTH search responses (emtee)
=== modified file 'dcpp/FavoriteManager.cpp'
--- dcpp/FavoriteManager.cpp 2013-12-06 00:08:00 +0000
+++ dcpp/FavoriteManager.cpp 2014-02-05 18:56:23 +0000
@@ -317,7 +317,7 @@
if(useHttp) {
try {
- File f(Util::getHubListsPath() + Util::validateFileName(publicListServer), File::WRITE, File::CREATE | File::TRUNCATE);
+ File f(Util::getHubListsPath() + Util::validatePath(publicListServer), File::WRITE, File::CREATE | File::TRUNCATE);
f.write(buf);
f.close();
} catch(const FileException&) { }
@@ -681,7 +681,7 @@
}
if(!forceDownload) {
- string path = Util::getHubListsPath() + Util::validateFileName(publicListServer);
+ string path = Util::getHubListsPath() + Util::validatePath(publicListServer);
if(File::getSize(path) > 0) {
useHttp = false;
string buf, fileDate;
=== modified file 'dcpp/LogManager.cpp'
--- dcpp/LogManager.cpp 2013-01-18 21:28:38 +0000
+++ dcpp/LogManager.cpp 2014-02-05 18:56:23 +0000
@@ -51,7 +51,7 @@
}
string LogManager::getPath(Area area, ParamMap& params) const {
- return SETTING(LOG_DIRECTORY) + Util::formatParams(getSetting(area, FILE), params, Util::cleanPathChars);
+ return SETTING(LOG_DIRECTORY) + Util::formatParams(getSetting(area, FILE), params, Util::validateFileName);
}
string LogManager::getPath(Area area) const {
@@ -70,7 +70,7 @@
void LogManager::log(const string& area, const string& msg) noexcept {
Lock l(cs);
try {
- string aArea = Util::validateFileName(area);
+ string aArea = Util::validatePath(area);
File::ensureDirectory(aArea);
File f(aArea, File::WRITE, File::OPEN | File::CREATE);
f.setEndPos(0);
=== modified file 'dcpp/QueueManager.cpp'
--- dcpp/QueueManager.cpp 2013-12-06 00:08:00 +0000
+++ dcpp/QueueManager.cpp 2014-02-05 18:56:23 +0000
@@ -519,7 +519,7 @@
string QueueManager::getListPath(const HintedUser& user) {
StringList nicks = ClientManager::getInstance()->getNicks(user);
- string nick = nicks.empty() ? Util::emptyString : Util::cleanPathChars(nicks[0]) + ".";
+ string nick = nicks.empty() ? Util::emptyString : Util::validateFileName(nicks[0]) + ".";
return checkTarget(Util::getListPath() + nick + user.user->getCID().toBase32(), /*checkExistence*/ false);
}
@@ -659,7 +659,7 @@
}
#endif
- string target = Util::validateFileName(aTarget);
+ string target = Util::validatePath(aTarget);
// Check that the file doesn't already exist...
if(checkExistence && File::getSize(target) != -1) {
@@ -813,7 +813,7 @@
void QueueManager::move(const string& aSource, const string& aTarget) noexcept {
- string target = Util::validateFileName(aTarget);
+ string target = Util::validatePath(aTarget);
if(aSource == target)
return;
=== modified file 'dcpp/Util.cpp'
--- dcpp/Util.cpp 2013-11-29 20:41:48 +0000
+++ dcpp/Util.cpp 2014-02-05 18:56:23 +0000
@@ -134,7 +134,7 @@
paths[PATH_USER_CONFIG] = paths[PATH_GLOBAL_CONFIG] + paths[PATH_USER_CONFIG];
}
- paths[PATH_USER_CONFIG] = validateFileName(paths[PATH_USER_CONFIG]);
+ paths[PATH_USER_CONFIG] = validatePath(paths[PATH_USER_CONFIG]);
if(localMode) {
paths[PATH_USER_LOCAL] = paths[PATH_USER_CONFIG];
@@ -174,7 +174,7 @@
paths[PATH_USER_CONFIG] = paths[PATH_GLOBAL_CONFIG] + paths[PATH_USER_CONFIG];
}
- paths[PATH_USER_CONFIG] = validateFileName(paths[PATH_USER_CONFIG]);
+ paths[PATH_USER_CONFIG] = validatePath(paths[PATH_USER_CONFIG]);
if(localMode) {
// @todo implement...
@@ -288,76 +288,84 @@
* Replaces all strange characters in a file with '_'
* @todo Check for invalid names such as nul and aux...
*/
-string Util::validateFileName(string tmp) {
- string::size_type i = 0;
-
- // First, eliminate forbidden chars
- while( (i = tmp.find_first_of(badChars, i)) != string::npos) {
- tmp[i] = '_';
- i++;
- }
-
- // Then, eliminate all ':' that are not the second letter ("c:\...")
- i = 0;
- while( (i = tmp.find(':', i)) != string::npos) {
- if(i == 1) {
- i++;
- continue;
- }
- tmp[i] = '_';
- i++;
- }
-
- // Remove the .\ that doesn't serve any purpose
- i = 0;
- while( (i = tmp.find("\\.\\", i)) != string::npos) {
- tmp.erase(i+1, 2);
- }
- i = 0;
- while( (i = tmp.find("/./", i)) != string::npos) {
- tmp.erase(i+1, 2);
- }
-
- // Remove any double \\ that are not at the beginning of the path...
- i = 1;
- while( (i = tmp.find("\\\\", i)) != string::npos) {
- tmp.erase(i+1, 1);
- }
- i = 1;
- while( (i = tmp.find("//", i)) != string::npos) {
- tmp.erase(i+1, 1);
- }
-
- // And last, but not least, the infamous ..\! ...
- i = 0;
- while( ((i = tmp.find("\\..\\", i)) != string::npos) ) {
- tmp[i + 1] = '_';
- tmp[i + 2] = '_';
- tmp[i + 3] = '_';
- i += 2;
- }
- i = 0;
- while( ((i = tmp.find("/../", i)) != string::npos) ) {
- tmp[i + 1] = '_';
- tmp[i + 2] = '_';
- tmp[i + 3] = '_';
- i += 2;
- }
-
- // Dots at the end of path names aren't popular
- i = 0;
- while( ((i = tmp.find(".\\", i)) != string::npos) ) {
- tmp[i] = '_';
- i += 1;
- }
- i = 0;
- while( ((i = tmp.find("./", i)) != string::npos) ) {
- tmp[i] = '_';
- i += 1;
- }
-
-
- return tmp;
+string Util::cleanPathChars(string tmp, bool isFileName) {
+ string::size_type i = 0;
+
+ // First, eliminate forbidden chars
+ while( (i = tmp.find_first_of(badChars, i)) != string::npos) {
+ tmp[i] = '_';
+ i++;
+ }
+
+ // Then, eliminate all ':' that are not the second letter ("c:\...")
+ i = 0;
+ while( (i = tmp.find(':', i)) != string::npos) {
+ if (i == 1 && !isFileName) {
+ i++;
+ continue;
+ }
+ tmp[i] = '_';
+ i++;
+ }
+
+ // Remove the .\ that doesn't serve any purpose
+ i = 0;
+ while( (i = tmp.find("\\.\\", i)) != string::npos) {
+ tmp.erase(i+1, 2);
+ }
+ i = 0;
+ while( (i = tmp.find("/./", i)) != string::npos) {
+ tmp.erase(i+1, 2);
+ }
+
+ // Remove any double \\ that are not at the beginning of the path...
+ i = isFileName ? 0 : 1;
+ while( (i = tmp.find("\\\\", i)) != string::npos) {
+ tmp.erase(i+1, 1);
+ }
+ i = isFileName ? 0 : 1;
+ while( (i = tmp.find("//", i)) != string::npos) {
+ tmp.erase(i+1, 1);
+ }
+
+ // And last, but not least, the infamous ..\! ...
+ i = 0;
+ while( ((i = tmp.find("\\..\\", i)) != string::npos) ) {
+ tmp[i + 1] = '_';
+ tmp[i + 2] = '_';
+ tmp[i + 3] = '_';
+ i += 2;
+ }
+ i = 0;
+ while( ((i = tmp.find("/../", i)) != string::npos) ) {
+ tmp[i + 1] = '_';
+ tmp[i + 2] = '_';
+ tmp[i + 3] = '_';
+ i += 2;
+ }
+
+ // Dots at the end of path names aren't popular
+ i = 0;
+ while( ((i = tmp.find(".\\", i)) != string::npos) ) {
+ if(i != 0)
+ tmp[i] = '_';
+ i += 1;
+ }
+ i = 0;
+ while( ((i = tmp.find("./", i)) != string::npos) ) {
+ if(i != 0)
+ tmp[i] = '_';
+ i += 1;
+ }
+
+ if (isFileName) {
+ i = 0;
+ while ((i = tmp.find(PATH_SEPARATOR, i)) != string::npos) {
+ tmp[i] = '_';
+ }
+ }
+
+ return tmp;
}
bool Util::checkExtension(const string& tmp) {
@@ -372,15 +380,6 @@
return true;
}
-string Util::cleanPathChars(const string& str) {
- string ret(str);
- string::size_type i = 0;
- while((i = ret.find_first_of("/.\\", i)) != string::npos) {
- ret[i] = '_';
- }
- return ret;
-}
-
string Util::addBrackets(const string& s) {
return '<' + s + '>';
}
=== modified file 'dcpp/Util.h'
--- dcpp/Util.h 2013-12-06 00:08:00 +0000
+++ dcpp/Util.h 2014-02-05 18:56:23 +0000
@@ -207,10 +207,11 @@
static void sanitizeUrl(string& url);
static void decodeUrl(const string& aUrl, string& protocol, string& host, string& port, string& path, string& query, string& fragment);
static map<string, string> decodeQuery(const string& query);
-
- static string validateFileName(string aFile);
+
+ static inline string validatePath(const string& aPath) { return cleanPathChars(aPath, false); }
+ static inline string validateFileName(const string& aFileName) { return cleanPathChars(aFileName, true); }
static bool checkExtension(const string& tmp);
- static string cleanPathChars(const string& str);
+ static string cleanPathChars(string aPath, bool isFileName);
static string addBrackets(const string& s);
static string formatBytes(const string& aString) { return formatBytes(toInt64(aString)); }
=== modified file 'win32/DirectoryListingFrame.cpp'
--- win32/DirectoryListingFrame.cpp 2013-03-16 14:57:07 +0000
+++ win32/DirectoryListingFrame.cpp 2014-02-05 18:56:23 +0000
@@ -1028,7 +1028,7 @@
try {
if(ii->type == ItemInfo::FILE) {
if(view) {
- File::deleteFile(dir + Util::validateFileName(ii->file->getName()));
+ File::deleteFile(dir + Util::validatePath(ii->file->getName()));
}
dl->download(ii->file, dir + Text::fromT(ii->getText(COLUMN_FILENAME)), view, WinUtil::isShift() || view);
} else if(!view) {
=== modified file 'win32/FinishedFrameBase.h'
--- win32/FinishedFrameBase.h 2013-03-16 14:57:07 +0000
+++ win32/FinishedFrameBase.h 2014-02-05 18:56:23 +0000
@@ -155,7 +155,7 @@
}
this->status->onDblClicked(STATUS_STATUS, [] {
- WinUtil::openFile(Text::toT(Util::validateFileName(LogManager::getInstance()->getPath(
+ WinUtil::openFile(Text::toT(Util::validatePath(LogManager::getInstance()->getPath(
in_UL ? LogManager::UPLOAD : LogManager::DOWNLOAD))));
});
=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp 2013-12-06 21:45:24 +0000
+++ win32/HubFrame.cpp 2014-02-05 18:56:23 +0000
@@ -1375,7 +1375,7 @@
params["hubNI"] = [this] { return client->getHubName(); };
params["hubURL"] = [this] { return client->getHubUrl(); };
params["myNI"] = [this] { return client->getMyNick(); };
- return Util::validateFileName(LogManager::getInstance()->getPath(status ? LogManager::STATUS : LogManager::CHAT, params));
+ return Util::validatePath(LogManager::getInstance()->getPath(status ? LogManager::STATUS : LogManager::CHAT, params));
}
void HubFrame::openLog(bool status) {
=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp 2014-02-02 22:40:28 +0000
+++ win32/MainWindow.cpp 2014-02-05 18:56:23 +0000
@@ -576,7 +576,7 @@
}
status->onDblClicked(STATUS_STATUS, [] {
- WinUtil::openFile(Text::toT(Util::validateFileName(LogManager::getInstance()->getPath(LogManager::SYSTEM))));
+ WinUtil::openFile(Text::toT(Util::validatePath(LogManager::getInstance()->getPath(LogManager::SYSTEM))));
});
status->onDblClicked(STATUS_AWAY, &Util::switchAway);
=== modified file 'win32/PrivateFrame.cpp'
--- win32/PrivateFrame.cpp 2013-11-29 20:41:48 +0000
+++ win32/PrivateFrame.cpp 2014-02-05 18:56:23 +0000
@@ -231,7 +231,7 @@
string PrivateFrame::getLogPath() const {
ParamMap params;
fillLogParams(params);
- return Util::validateFileName(LogManager::getInstance()->getPath(LogManager::PM, params));
+ return Util::validatePath(LogManager::getInstance()->getPath(LogManager::PM, params));
}
void PrivateFrame::openLog() {
=== modified file 'win32/SystemFrame.cpp'
--- win32/SystemFrame.cpp 2013-03-16 14:57:07 +0000
+++ win32/SystemFrame.cpp 2014-02-05 18:56:23 +0000
@@ -50,7 +50,7 @@
initStatus();
status->onDblClicked(STATUS_STATUS, [] {
- WinUtil::openFile(Text::toT(Util::validateFileName(LogManager::getInstance()->getPath(LogManager::SYSTEM))));
+ WinUtil::openFile(Text::toT(Util::validatePath(LogManager::getInstance()->getPath(LogManager::SYSTEM))));
});
layout();
=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp 2014-02-02 22:48:09 +0000
+++ win32/WinUtil.cpp 2014-02-05 18:56:23 +0000
@@ -604,12 +604,12 @@
if(Util::stricmp(cmd.c_str(), _T("log")) == 0) {
if(Util::stricmp(param.c_str(), _T("system")) == 0) {
- WinUtil::openFile(Text::toT(Util::validateFileName(LogManager::getInstance()->getPath(LogManager::SYSTEM))));
+ WinUtil::openFile(Text::toT(Util::validatePath(LogManager::getInstance()->getPath(LogManager::SYSTEM))));
} else if(Util::stricmp(param.c_str(), _T("downloads")) == 0) {
WinUtil::openFile(Text::toT(
- Util::validateFileName(LogManager::getInstance()->getPath(LogManager::DOWNLOAD))));
+ Util::validatePath(LogManager::getInstance()->getPath(LogManager::DOWNLOAD))));
} else if(Util::stricmp(param.c_str(), _T("uploads")) == 0) {
- WinUtil::openFile(Text::toT(Util::validateFileName(LogManager::getInstance()->getPath(LogManager::UPLOAD))));
+ WinUtil::openFile(Text::toT(Util::validatePath(LogManager::getInstance()->getPath(LogManager::UPLOAD))));
} else {
return false;
}