Downloads folder now is movable

This commit is contained in:
Blue 2022-02-19 21:31:49 +03:00
parent d8b5ccb2da
commit 73b1b58a96
Signed by: blue
GPG key ID: 9B203B252A63EE38
16 changed files with 141 additions and 12 deletions

View file

@ -438,10 +438,10 @@ void Core::NetworkAccess::onUploadProgress(qint64 bytesReceived, qint64 bytesTot
QString Core::NetworkAccess::getFileRemoteUrl(const QString& path)
{
QString p;
QString p = Shared::squawkifyPath(path);
try {
p = storage.getUrl(path);
p = storage.getUrl(p);
} catch (const Archive::NotFound& err) {
} catch (...) {
@ -574,10 +574,16 @@ std::list<Shared::MessageInfo> Core::NetworkAccess::reportPathInvalid(const QStr
void Core::NetworkAccess::moveFilesDirectory(const QString& newPath)
{
QDir dir;
if (dir.rename(currentPath, newPath)) {
currentPath = newPath;
} else {
QDir dir(currentPath);
bool success = true;
qDebug() << "moving" << currentPath << "to" << newPath;
for (QFileInfo fileInfo : dir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System)) {
QString fileName = fileInfo.fileName();
success = dir.rename(fileName, newPath + QDir::separator() + fileName) && success;
}
if (!success) {
qDebug() << "couldn't move downloads directory, most probably downloads will be broken";
}
currentPath = newPath;
}