Skip to content

Commit 9267edc

Browse files
committed
Minor fix for renaming
1 parent 0a52213 commit 9267edc

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

main.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -307,18 +307,21 @@ void MainWindow::run_copy_thread(MainWindow *w) {
307307
while(!w->copy_queue.isEmpty()) {
308308
file = w->copy_queue.dequeue();
309309

310+
QFileInfo new_file = QFileInfo(file.second);
310311

311-
if(QFile(file.second).exists()) {
312-
qDebug("Destination already exists, renaming");
313-
int i = 1;
314-
while(QFile(file.second + "_" + i).exists()) { i++; }
312+
if(new_file.exists()) {
313+
qDebug("File exists, renaming...");
314+
QString new_file_name = QDir(new_file.absolutePath()).filePath(new_file.baseName());
315315

316-
qDebug("Copying %s to %s", file.first.toStdString().c_str(), (file.second + "_" + i).toStdString().c_str());
317-
QFile::copy(file.first, file.second + "_" + i);
318-
} else {
319-
qDebug("Copying %s to %s", file.first.toStdString().c_str(), file.second.toStdString().c_str());
320-
QFile::copy(file.first, file.second);
316+
int i = 1;
317+
while(new_file.exists()) {
318+
new_file = QFileInfo(QString("%1_%2.%3").arg(new_file_name, QString::number(i), new_file.suffix()));
319+
i++;
320+
}
321321
}
322+
323+
qDebug("Copying %s to %s", file.first.toStdString().c_str(), new_file.filePath().toStdString().c_str());
324+
QFile::copy(file.first, new_file.filePath());
322325
}
323326
w->ui->button_go->setEnabled(true);
324327
}

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"database-version": 10,
3-
"main-version": 7
3+
"main-version": 8
44
}

0 commit comments

Comments
 (0)