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:
alexandrut 2009-07-28 15:29:21 +00:00
parent e68d874406
commit 3394239297
2 changed files with 31 additions and 7 deletions

View File

@ -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 */

View File

@ -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()