mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #1262 from PhenomRetroShare/Fix_PartialDirCheck
Fix Partial Dir Check
This commit is contained in:
commit
2145911ac4
@ -1472,24 +1472,24 @@ bool ftController::setPartialsDirectory(std::string path)
|
|||||||
|
|
||||||
/* check it is not a subdir of download / shared directories (BAD) - TODO */
|
/* check it is not a subdir of download / shared directories (BAD) - TODO */
|
||||||
{
|
{
|
||||||
RsStackMutex stack(ctrlMutex);
|
RsStackMutex stack(ctrlMutex);
|
||||||
|
|
||||||
path = RsDirUtil::convertPathToUnix(path);
|
path = RsDirUtil::convertPathToUnix(path);
|
||||||
|
|
||||||
if (path.find(mDownloadPath) == std::string::npos) {
|
if (path.find(mDownloadPath) != std::string::npos) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rsFiles) {
|
if (rsFiles) {
|
||||||
std::list<SharedDirInfo>::iterator it;
|
std::list<SharedDirInfo>::iterator it;
|
||||||
std::list<SharedDirInfo> dirs;
|
std::list<SharedDirInfo> dirs;
|
||||||
rsFiles->getSharedDirectories(dirs);
|
rsFiles->getSharedDirectories(dirs);
|
||||||
for (it = dirs.begin(); it != dirs.end(); ++it) {
|
for (it = dirs.begin(); it != dirs.end(); ++it) {
|
||||||
if (path.find((*it).filename) == std::string::npos) {
|
if (path.find((*it).filename) != std::string::npos) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if it exists */
|
/* check if it exists */
|
||||||
|
@ -175,8 +175,8 @@ class ftController: public RsTickingThread, public pqiServiceMonitor, public p3C
|
|||||||
void FileDownloads(std::list<RsFileHash> &hashs);
|
void FileDownloads(std::list<RsFileHash> &hashs);
|
||||||
|
|
||||||
/* Directory Handling */
|
/* Directory Handling */
|
||||||
bool setDownloadDirectory(std::string path);
|
bool setDownloadDirectory(std::string path);
|
||||||
bool setPartialsDirectory(std::string path);
|
bool setPartialsDirectory(std::string path);
|
||||||
std::string getDownloadDirectory();
|
std::string getDownloadDirectory();
|
||||||
std::string getPartialsDirectory();
|
std::string getPartialsDirectory();
|
||||||
bool FileDetails(const RsFileHash &hash, FileInfo &info);
|
bool FileDetails(const RsFileHash &hash, FileInfo &info);
|
||||||
|
@ -23,35 +23,40 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <time.h>
|
|
||||||
#include "util/rsdebug.h"
|
|
||||||
#include "util/rsdir.h"
|
|
||||||
#include "util/rsprint.h"
|
|
||||||
#include "crypto/chacha20.h"
|
#include "crypto/chacha20.h"
|
||||||
#include "retroshare/rstypes.h"
|
|
||||||
#include "retroshare/rspeers.h"
|
|
||||||
//const int ftserverzone = 29539;
|
//const int ftserverzone = 29539;
|
||||||
|
|
||||||
#include "file_sharing/p3filelists.h"
|
#include "file_sharing/p3filelists.h"
|
||||||
#include "ft/ftturtlefiletransferitem.h"
|
|
||||||
#include "ft/ftserver.h"
|
|
||||||
#include "ft/ftextralist.h"
|
|
||||||
#include "ft/ftfilesearch.h"
|
|
||||||
#include "ft/ftcontroller.h"
|
#include "ft/ftcontroller.h"
|
||||||
#include "ft/ftfileprovider.h"
|
|
||||||
#include "ft/ftdatamultiplex.h"
|
#include "ft/ftdatamultiplex.h"
|
||||||
//#include "ft/ftdwlqueue.h"
|
//#include "ft/ftdwlqueue.h"
|
||||||
#include "turtle/p3turtle.h"
|
#include "ft/ftextralist.h"
|
||||||
#include "pqi/p3notify.h"
|
#include "ft/ftfileprovider.h"
|
||||||
#include "rsserver/p3face.h"
|
#include "ft/ftfilesearch.h"
|
||||||
|
#include "ft/ftserver.h"
|
||||||
|
#include "ft/ftturtlefiletransferitem.h"
|
||||||
|
|
||||||
#include "pqi/pqi.h"
|
|
||||||
#include "pqi/p3linkmgr.h"
|
#include "pqi/p3linkmgr.h"
|
||||||
|
#include "pqi/p3notify.h"
|
||||||
|
#include "pqi/pqi.h"
|
||||||
|
|
||||||
|
#include "retroshare/rstypes.h"
|
||||||
|
#include "retroshare/rspeers.h"
|
||||||
|
|
||||||
#include "rsitems/rsfiletransferitems.h"
|
#include "rsitems/rsfiletransferitems.h"
|
||||||
#include "rsitems/rsserviceids.h"
|
#include "rsitems/rsserviceids.h"
|
||||||
|
|
||||||
|
#include "rsserver/p3face.h"
|
||||||
|
#include "rsserver/rsaccounts.h"
|
||||||
|
#include "turtle/p3turtle.h"
|
||||||
|
|
||||||
|
#include "util/rsdebug.h"
|
||||||
|
#include "util/rsdir.h"
|
||||||
|
#include "util/rsprint.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* #define SERVER_DEBUG 1
|
* #define SERVER_DEBUG 1
|
||||||
* #define SERVER_DEBUG_CACHE 1
|
* #define SERVER_DEBUG_CACHE 1
|
||||||
@ -145,9 +150,19 @@ void ftServer::SetupFtServer()
|
|||||||
/* make Controller */
|
/* make Controller */
|
||||||
mFtController = new ftController(mFtDataplex, mServiceCtrl, getServiceInfo().mServiceType);
|
mFtController = new ftController(mFtDataplex, mServiceCtrl, getServiceInfo().mServiceType);
|
||||||
mFtController -> setFtSearchNExtra(mFtSearch, mFtExtra);
|
mFtController -> setFtSearchNExtra(mFtSearch, mFtExtra);
|
||||||
std::string tmppath = ".";
|
|
||||||
mFtController->setPartialsDirectory(tmppath);
|
std::string emergencySaveDir = rsAccounts->PathAccountDirectory();
|
||||||
mFtController->setDownloadDirectory(tmppath);
|
std::string emergencyPartialsDir = rsAccounts->PathAccountDirectory();
|
||||||
|
if (emergencySaveDir != "")
|
||||||
|
{
|
||||||
|
emergencySaveDir += "/";
|
||||||
|
emergencyPartialsDir += "/";
|
||||||
|
}
|
||||||
|
emergencySaveDir += "Downloads";
|
||||||
|
emergencyPartialsDir += "Partials";
|
||||||
|
|
||||||
|
mFtController->setDownloadDirectory(emergencySaveDir);
|
||||||
|
mFtController->setPartialsDirectory(emergencyPartialsDir);
|
||||||
|
|
||||||
/* complete search setup */
|
/* complete search setup */
|
||||||
mFtSearch->addSearchMode(mFtExtra, RS_FILE_HINTS_EXTRA);
|
mFtSearch->addSearchMode(mFtExtra, RS_FILE_HINTS_EXTRA);
|
||||||
@ -412,9 +427,9 @@ void ftServer::requestDirUpdate(void *ref)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Directory Handling */
|
/* Directory Handling */
|
||||||
void ftServer::setDownloadDirectory(std::string path)
|
bool ftServer::setDownloadDirectory(std::string path)
|
||||||
{
|
{
|
||||||
mFtController->setDownloadDirectory(path);
|
return mFtController->setDownloadDirectory(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ftServer::getDownloadDirectory()
|
std::string ftServer::getDownloadDirectory()
|
||||||
@ -422,9 +437,9 @@ std::string ftServer::getDownloadDirectory()
|
|||||||
return mFtController->getDownloadDirectory();
|
return mFtController->getDownloadDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ftServer::setPartialsDirectory(std::string path)
|
bool ftServer::setPartialsDirectory(std::string path)
|
||||||
{
|
{
|
||||||
mFtController->setPartialsDirectory(path);
|
return mFtController->setPartialsDirectory(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ftServer::getPartialsDirectory()
|
std::string ftServer::getPartialsDirectory()
|
||||||
|
@ -202,8 +202,8 @@ public:
|
|||||||
* Directory Handling
|
* Directory Handling
|
||||||
***/
|
***/
|
||||||
virtual void requestDirUpdate(void *ref) ; // triggers the update of the given reference. Used when browsing.
|
virtual void requestDirUpdate(void *ref) ; // triggers the update of the given reference. Used when browsing.
|
||||||
virtual void setDownloadDirectory(std::string path);
|
virtual bool setDownloadDirectory(std::string path);
|
||||||
virtual void setPartialsDirectory(std::string path);
|
virtual bool setPartialsDirectory(std::string path);
|
||||||
virtual std::string getDownloadDirectory();
|
virtual std::string getDownloadDirectory();
|
||||||
virtual std::string getPartialsDirectory();
|
virtual std::string getPartialsDirectory();
|
||||||
|
|
||||||
|
@ -278,8 +278,8 @@ class RsFiles
|
|||||||
***/
|
***/
|
||||||
virtual void requestDirUpdate(void *ref) =0 ; // triggers the update of the given reference. Used when browsing.
|
virtual void requestDirUpdate(void *ref) =0 ; // triggers the update of the given reference. Used when browsing.
|
||||||
|
|
||||||
virtual void setDownloadDirectory(std::string path) = 0;
|
virtual bool setDownloadDirectory(std::string path) = 0;
|
||||||
virtual void setPartialsDirectory(std::string path) = 0;
|
virtual bool setPartialsDirectory(std::string path) = 0;
|
||||||
virtual std::string getDownloadDirectory() = 0;
|
virtual std::string getDownloadDirectory() = 0;
|
||||||
virtual std::string getPartialsDirectory() = 0;
|
virtual std::string getPartialsDirectory() = 0;
|
||||||
|
|
||||||
|
@ -244,9 +244,15 @@ OpModeStatus[opMode="Minimal"] {
|
|||||||
background: #FFCCCC;
|
background: #FFCCCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Property Values at end to overwrite other settings*/
|
||||||
|
|
||||||
[new=false] {
|
[new=false] {
|
||||||
background: #F8F8F8;
|
background: #F8F8F8;
|
||||||
}
|
}
|
||||||
[new=true] {
|
[new=true] {
|
||||||
background: #DCECFD;
|
background: #DCECFD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[WrongValue="true"] {
|
||||||
|
background-color: #FF8080;
|
||||||
|
}
|
||||||
|
@ -22,15 +22,17 @@
|
|||||||
#include "TransferPage.h"
|
#include "TransferPage.h"
|
||||||
|
|
||||||
#include "rshare.h"
|
#include "rshare.h"
|
||||||
|
#include "gui/ShareManager.h"
|
||||||
|
#include "util/misc.h"
|
||||||
|
|
||||||
|
#include "retroshare/rsiface.h"
|
||||||
|
#include "retroshare/rsfiles.h"
|
||||||
|
#include "retroshare/rspeers.h"
|
||||||
|
|
||||||
|
#include <QToolTip>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <util/misc.h>
|
|
||||||
#include <gui/ShareManager.h>
|
|
||||||
#include <retroshare/rsiface.h>
|
|
||||||
#include <retroshare/rsfiles.h>
|
|
||||||
#include <retroshare/rspeers.h>
|
|
||||||
|
|
||||||
TransferPage::TransferPage(QWidget * parent, Qt::WindowFlags flags)
|
TransferPage::TransferPage(QWidget * parent, Qt::WindowFlags flags)
|
||||||
: ConfigPage(parent, flags)
|
: ConfigPage(parent, flags)
|
||||||
{
|
{
|
||||||
@ -225,11 +227,23 @@ void TransferPage::setIncomingDirectory()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.incomingDir->setText(qdir);
|
std::string dir = qdir.toUtf8().constData();
|
||||||
std::string dir = ui.incomingDir->text().toUtf8().constData();
|
if(!dir.empty())
|
||||||
|
{
|
||||||
if(!dir.empty())
|
if (!rsFiles->setDownloadDirectory(dir))
|
||||||
rsFiles->setDownloadDirectory(dir);
|
{
|
||||||
|
ui.incomingDir->setToolTip( tr("Invalid Input. Have you got the right to write on it?") );
|
||||||
|
ui.incomingDir->setProperty("WrongValue", true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui.incomingDir->setToolTip( "" );
|
||||||
|
ui.incomingDir->setProperty("WrongValue", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui.incomingDir->style()->unpolish(ui.incomingDir);
|
||||||
|
ui.incomingDir->style()->polish( ui.incomingDir);
|
||||||
|
whileBlocking(ui.incomingDir)->setText(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferPage::setPartialsDirectory()
|
void TransferPage::setPartialsDirectory()
|
||||||
@ -239,11 +253,25 @@ void TransferPage::setPartialsDirectory()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.partialsDir->setText(qdir);
|
std::string dir = qdir.toUtf8().constData();
|
||||||
std::string dir = ui.partialsDir->text().toUtf8().constData();
|
|
||||||
if (!dir.empty())
|
if (!dir.empty())
|
||||||
rsFiles->setPartialsDirectory(dir);
|
{
|
||||||
|
if (!rsFiles->setPartialsDirectory(dir))
|
||||||
|
{
|
||||||
|
ui.partialsDir->setToolTip( tr("Invalid Input. It can't be an already shared directory.") );
|
||||||
|
ui.partialsDir->setProperty("WrongValue", true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui.partialsDir->setToolTip( "" );
|
||||||
|
ui.partialsDir->setProperty("WrongValue", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui.partialsDir->style()->unpolish(ui.partialsDir);
|
||||||
|
ui.partialsDir->style()->polish( ui.partialsDir);
|
||||||
|
whileBlocking(ui.partialsDir)->setText(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferPage::toggleAutoCheckDirectories(bool b)
|
void TransferPage::toggleAutoCheckDirectories(bool b)
|
||||||
{
|
{
|
||||||
ui.autoCheckDirectoriesDelay_SB->setEnabled(b);
|
ui.autoCheckDirectoriesDelay_SB->setEnabled(b);
|
||||||
|
@ -293,9 +293,16 @@ OpModeStatus[opMode="Minimal"] {
|
|||||||
background: #700000;
|
background: #700000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Property Values at end to overwrite other settings*/
|
||||||
|
|
||||||
[new=false] {
|
[new=false] {
|
||||||
background: #202020;
|
background: #202020;
|
||||||
}
|
}
|
||||||
[new=true] {
|
[new=true] {
|
||||||
background: #005000;
|
background: #005000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[WrongValue=true] {
|
||||||
|
background-color: #702020;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1126,9 +1126,15 @@ OpModeStatus[opMode="Minimal"] {
|
|||||||
background: #700000;
|
background: #700000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Property Values at end to overwrite other settings*/
|
||||||
|
|
||||||
[new=false] {
|
[new=false] {
|
||||||
background: #202020;
|
background: #202020;
|
||||||
}
|
}
|
||||||
[new=true] {
|
[new=true] {
|
||||||
background: #005000;
|
background: #005000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[WrongValue="true"] {
|
||||||
|
background-color: #702020;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user