mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
let hash name for partial files, use qfile link instead
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1448 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e68d874406
commit
3394239297
@ -735,7 +735,7 @@ bool ftController::FileRequest(std::string fname, std::string hash,
|
||||
|
||||
{ RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
savepath = mPartialsPath + "/" + fname;
|
||||
savepath = mPartialsPath + "/" + hash;
|
||||
destination = dest + "/" + fname;
|
||||
|
||||
/* if no destpath - send to download directory */
|
||||
|
@ -1094,21 +1094,45 @@ void TransfersDialog::previewTransfer()
|
||||
if (!misc::isPreviewable(info.fname.substr(pos + 1).c_str())) return;
|
||||
|
||||
/* make path for downloaded or downloading files */
|
||||
QFileInfo qinfo;
|
||||
bool complete = false;
|
||||
std::string path;
|
||||
if (info.downloadStatus == FT_STATE_COMPLETE) {
|
||||
path = info.path + "/" + info.fname;
|
||||
complete = true;
|
||||
} else {
|
||||
path = rsFiles->getPartialsDirectory() + "/" + info.fname;
|
||||
path = rsFiles->getPartialsDirectory() + "/" + info.hash;
|
||||
}
|
||||
|
||||
/* open or preview them with a suitable application */
|
||||
qinfo.setFile(path.c_str());
|
||||
QFileInfo qinfo;
|
||||
if (complete) {
|
||||
qinfo.setFile(QString::fromStdString(path));
|
||||
if (qinfo.exists()) {
|
||||
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
|
||||
std::cerr << "previewTransfer(): can't preview file " << path << std::endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QString linkName = QString::fromStdString(path) +
|
||||
QString::fromStdString(info.fname.substr(info.fname.find_last_of('.')));
|
||||
if (QFile::link(QString::fromStdString(path), linkName)) {
|
||||
qinfo.setFile(linkName);
|
||||
if (qinfo.exists()) {
|
||||
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(qinfo.absoluteFilePath()))) {
|
||||
std::cerr << "previewTransfer(): can't preview file " << path << std::endl;
|
||||
}
|
||||
}
|
||||
/* wait for the file to open then remove the link */
|
||||
#ifdef WIN32
|
||||
Sleep(2000);
|
||||
#else
|
||||
sleep(2);
|
||||
#endif
|
||||
QFile::remove(linkName);
|
||||
} else {
|
||||
std::cerr << "previewTransfer(): can't create link for file " << path << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TransfersDialog::openTransfer()
|
||||
|
Loading…
Reference in New Issue
Block a user