Commit d3acacad authored by Bart De Vries's avatar Bart De Vries Committed by Nate Graham
Browse files

Solve a bug which can happen with multiple files with the same name

Summary:
In case there are two or more files with the same name in the source
(e.g. in separate subfolders), and if an identical file with that
name also exists in the destination, then a dialog will pop up asking
for user intervention (overwrite, ignore, cancel).

The reason is the following:
- File1 will get copied into the temporary import folder.  In case
  an identical file with that name already exists in the destination,
  this file will be skipped.  I.e. the file will not be moved, and
  stays in the temporary folder.
- File2 (with identical name) gets copied into the temporary folder.
  However, a file with that name will already exist, so a dialog
  box will pop up to ask for user input.

Since this can only happen if file1 has been skipped (otherwise
it would have been moved out of the temporary folder), file2 should
always overwrite file1.  Otherwise, if file1 and file2 share the
same name but are not identical, unexpected things might happen and
data might be lost.

Test Plan:
Tested with the situation described above: multiple files with the
same name in the source and destination folders, with or without
identical contents.
With this patch, no dialog box pops up, and the correct import
action is done.

Reviewers: #gwenview, ngraham

Reviewed By: #gwenview, ngraham

Subscribers: ngraham

Tags: #gwenview

Differential Revision: https://phabricator.kde.org/D25224
parent d5bdae6c
......@@ -107,7 +107,7 @@ struct ImporterPrivate
mCurrentUrl = mUrlList.takeFirst();
QUrl dst = mTempImportDirUrl;
dst.setPath(dst.path() + mCurrentUrl.fileName());
KIO::Job* job = KIO::copy(mCurrentUrl, dst, KIO::HideProgressInfo);
KIO::Job* job = KIO::copy(mCurrentUrl, dst, KIO::HideProgressInfo|KIO::Overwrite);
KJobWidgets::setWindow(job, mAuthWindow);
QObject::connect(job, &KJob::result,
q, &Importer::slotCopyDone);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment