History

Switched saving download/upload to temporary directory

elisa-lj11 committed 10 years ago

Commit a9a87101 parent b1b2ea44 files · +16 −17Browse files

Showing the changes to libraries/script-engine/src/FileScriptingInterface.cpp (1 of 4 files). Show all

Unified · Split

libraries/script-engine/src/FileScriptingInterface.cpp+8−6
@@ -31,10 +31,10 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent · 30 unmodified lines
3131 // nothing for now
3232 }
3333
34−void FileScriptingInterface::runUnzip(QString path, QUrl url) {
34+void FileScriptingInterface::runUnzip(QString path, QString tempDir, QUrl url) {
3535 qDebug() << "Url that was downloaded: " + url.toString();
3636 qDebug() << "Path where download is saved: " + path;
37− QString file = unzipFile(path);
37+ QString file = unzipFile(path, tempDir);
3838 if (file != "") {
3939 qDebug() << "file to upload: " + file;
4040 QUrl url = QUrl::fromLocalFile(file);
@@ -43,6 +43,8 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url) { · 2 unmodified lines
4343 } else {
4444 qDebug() << "unzip failed";
4545 }
46+ qDebug() << "Removing temporary directory at: " + tempDir;
47+ QDir(tempDir).removeRecursively();
4648 }
4749
4850 bool FileScriptingInterface::testUrl(QUrl url) {
@@ -72,20 +74,20 @@ void FileScriptingInterface::downloadZip(QString path, const QString link) { · 23 unmodified lines
7274 QUrl url = QUrl(link);
7375 auto request = ResourceManager::createResourceRequest(nullptr, url);
7476 connect(request, &ResourceRequest::finished, this, [this, path]{
75− unzipFile(path);
77+ unzipFile(path, ""); // so intellisense isn't mad
7678 });
7779 request->send();
7880 }
7981
8082
81−QString FileScriptingInterface::unzipFile(QString path) {
83+QString FileScriptingInterface::unzipFile(QString path, QString tempDir) {
8284
8385 QDir dir(path);
8486 QString dirName = dir.path();
8587 qDebug() << "Zip directory is stored at: " + dirName;
86− QString target = path.section("/", -1) + "/model_repo";
88+ QString target = tempDir + "/model_repo";
8789 qDebug() << "Target path: " + target;
88− QStringList list = JlCompress::extractDir(dirName, "C:/Users/elisa/Downloads/test");
90+ QStringList list = JlCompress::extractDir(dirName, target);
8991
9092 qDebug() << list;
9193